Message117864
Python 3.1 improves the situation, the file looks more like utf-16, except that the BOM ("\xff\xfe") is repeated all the time, probably on every internal call to file.write().
Here is a test script that should work on both 2.7 and 3.1.
from io import BytesIO
from xml.etree.ElementTree import ElementTree
content = "<?xml version='1.0' encoding='UTF-16'?><html></html>"
input = BytesIO(content.encode('utf-16'))
tree = ElementTree()
tree.parse(input)
# Write content
output = BytesIO()
tree.write(output, encoding="utf-16")
assert output.getvalue().decode('utf-16') == content |
|
Date |
User |
Action |
Args |
2010-10-02 09:56:31 | amaury.forgeotdarc | set | recipients:
+ amaury.forgeotdarc, effbot, nnorwitz, bugok, rurwin, flox, BreamoreBoy, Richard.Urwin |
2010-10-02 09:56:31 | amaury.forgeotdarc | set | messageid: <1286013391.41.0.658493601343.issue1767933@psf.upfronthosting.co.za> |
2010-10-02 09:56:28 | amaury.forgeotdarc | link | issue1767933 messages |
2010-10-02 09:56:28 | amaury.forgeotdarc | create | |
|