Changeset 5197
- Timestamp:
- 05/12/07 00:29:10 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/unicode/django/http/__init__.py
r5184 r5197 361 361 def str_to_unicode(s, encoding): 362 362 """ 363 Convert basestring objects to unicode, using the given encoding. 363 Convert basestring objects to unicode, using the given encoding. Illegaly 364 encoded input characters are replaced with Unicode "unknown" codepoint 365 (\ufffd). 364 366 365 367 Returns any non-basestring objects without change. 366 368 """ 367 369 if isinstance(s, str): 368 return unicode(s, encoding )370 return unicode(s, encoding, 'replace') 369 371 else: 370 372 return s django/branches/unicode/tests/regressiontests/httpwrappers/tests.py
r5184 r5197 368 368 'vote=yes&vote=no' 369 369 370 # QueryDicts must be able to handle invalid input encoding (in this case, bad 371 # UTF-8 encoding). 372 >>> q = QueryDict('foo=bar&foo=\xff') 373 374 >>> q['foo'] 375 u'\ufffd' 376 377 >>> q.getlist('foo') 378 [u'bar', u'\ufffd'] 379 370 380 """ 371 381
