XMLGenerator / StringIO / ordinal not in range

Martin v. Löwis loewis at informatik.hu-berlin.de
Tue Oct 15 09:11:28 EDT 2002


"Achim Domma" <achim.domma at syynx.de> writes:

> I try to produce an XML string in memory using XMLGenerator and StringIO.
> Everything works fine as long as I dont' try to write Non-ASCII charakters
> to the stream. If I would write to file, I would open it with codecs.open,
> but how can I tell StringIO to accept utf-8 encoding?

If you use non-ASCII characters, you need to represent them in Unicode
strings, not in byte strings. The SAX API uses Unicode throughout.

Regards,
Martin



More information about the Python-list mailing list