Message169180
| Author |
petri.lehtinen |
| Recipients |
docs@python, ezio.melotti, petri.lehtinen, rhettinger, socketpair, terry.reedy |
| Date |
2012年08月27日.05:00:14 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1346043615.43.0.759302166798.issue13769@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
It seems to me that when ensure_ascii is False, the return value will be a unicode instance if and only if there's a unicode object anywhere in the input.
>>> json.dumps({'foo': 'bar'}, ensure_ascii=False)
'{"foo": "bar"}'
>>> json.dumps({'foo': u'bar'}, ensure_ascii=False)
u'{"foo": "bar"}'
>>> json.dumps({'foo': u'äiti'}, ensure_ascii=False)
u'{"foo": "\xe4iti"}'
>>> json.dumps({'foo': u'äiti'.encode('utf-8')}, ensure_ascii=False)
'{"foo": "\xc3\xa4iti"}'
>>> json.dumps({'foo': u'äiti'.encode('utf-16')}, ensure_ascii=False)
'{"foo": "\xff\xfe\xe4\\u0000i\\u0000t\\u0000i\\u0000"}' |
|