Message93106
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. |
|
Date |
User |
Action |
Args |
2009-09-25 15:10:41 | vinay.sajip | set | recipients:
+ vinay.sajip, methane |
2009-09-25 15:10:41 | vinay.sajip | set | messageid: <1253891441.05.0.42390735918.issue6991@psf.upfronthosting.co.za> |
2009-09-25 15:10:39 | vinay.sajip | link | issue6991 messages |
2009-09-25 15:10:38 | vinay.sajip | create | |
|