Unicode (inc. Japanese) in Python and TK

Martin v. Löwis loewis at informatik.hu-berlin.de
Fri Sep 27 14:59:39 CEST 2002


gtaylor at lowebroadway.com (Garry Taylor) writes:

> I'm just seeking a little reassurance regarding use of unicode in
> Python, before I write my program, and then later find out I'm going
> to have to re-write in Java or something. Basically, am I going to run
> into any brick walls by doing the following:

It will all work out well if you are willing to adjust your
understanding of character sets, and Unicode, in the process of
developing this application.

> 1) Parsing XML with unicode characters.

XML, per se, does not have 'unicode characters'. XML is typically
stored in files, or other byte sequences. Those byte sequences have an
encoding. If the encoding is known to Python, you can parse the
document. Python will represent the strings as Unicode objects to you.

> 2) Measuring unicode characters using TK

I'm not sure whether this is possible.

> 3) Printing unicode to a file

Same comments as 1): If you know what encoding you want to use in the
file, and if Python supports that encoding, it will work. "unicode" is
not an encoding; "utf-8" and "ucs-2" are.

Regards,
Martin



More information about the Python-list mailing list