Vinay Sajip <vinay_sa...@yahoo.co.uk> added the comment: There seems to be a problem with your foo.py. In it, you are writing a byte-string to a stream returned from codecs.open. I don't think this is correct: you should be writing a Unicode string to that stream, which will convert to bytes using the stream's encoding, and write those bytes to file. The following snippet illustrates:
>>> import codecs >>> f = codecs.open('foo.txt', 'w', encoding='utf-8') >>> f.write(u'\u76F4\u6A39\u7A32\u7530') >>> f.close() >>> f = open('foo.txt', 'r') >>> f.read() '\xe7\x9b\xb4\xe6\xa8\xb9\xe7\xa8\xb2\xe7\x94\xb0' As you can see, the Unicode has been converted using UTF-8. ---------- status: open -> pending _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue6991> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com