minidom utf-8 encoding

"Martin v. Löwis" martin at v.loewis.de
Thu Jan 4 11:40:15 EST 2007


fscked schrieb:
> Well, let me clarify. If I just print it to the screen/console it works
> fine, but when I do:
> 
> out.write( doc.toprettyxml())
> 
> it just removes the character that would be the "ö".
> 
> I can post the code if anyone wants to see it, but it is fairly
> straightforward.

I find that hard to believe. There is no code in Python that does
removal of characters, and I can't see any other reason why it gets
removed.

OTOH, what I do get when writing to a file is a UnicodeError, when
it tries to convert the Unicode string that toxml gives to a byte
string.

So I recommend you pass encoding="utf-8" to the toprettyxml invocation
also.

Regards,
Martin



More information about the Python-list mailing list