Unicode File Conversion

Martin von Loewis loewis at informatik.hu-berlin.de
Fri Aug 3 10:33:53 CEST 2001


Tksee Lhsoh <tksee at yahoo.com> writes:

> I would like to convert unicode strings to strings of a ceratin code
> such as ISO 8859-1 and ISO 8859-2 in Europe, ISO 8859-7 in Greece,
> EUC and Shift-JIS in Japan,...
>
> And would be really glad if there are any converters!

To convert a Unicode string to ISO 8859-1, just do

thestring.encode("iso-8859-1")

The same works for all of ISO 8859; the relevant codecs are supported
in the standard python library. For other codecs, please have a look at

http://sourceforge.net/projects/python-codecs

There are specific codecs for Chinese, Japanese, and Korean encodings
in the practicecodecs CVS directory, and an iconv codec to expose all
codecs of your Unix C library.

Regards,
Martin




More information about the Python-list mailing list