unicode + xml

Stefan Behnel stefan_ml at behnel.de
Tue Sep 8 02:50:28 EDT 2009


Laurent Luce wrote:
> Can someone confirm that the issue here is I need to encode the xml data using:
> # encode as UTF-8
> utf8_string = xml.encode( 'utf-8' )
> and then post it to the server.

Well, since you declared it to be UTF-8, it must be UTF-8 encoded.

However, your question seems to imply that you generate the XML manually
using string concatenation, which is a rather bad idea. Python has great
XML tools like ElementTree that help in generating and serialising XML
correctly (besides parsing, searching and other things).

Stefan



More information about the Python-list mailing list