[Pythonmac-SIG] charset conversions

Just van Rossum just@letterror.com
Fri, 8 Sep 2000 14:22:27 +0100


At 1:57 PM +0200 08-09-2000, tmk [microscript] wrote:
>Yo,
>
>I'm looking into doing character set conversions in Python (e.g. from
>MacRoman to ISO-8859-1).
>
>I was wondering if it already exists some stuff in this area. I've tried
>looking in the current library of python modules but I was unable to find
>something of interest.
>
>Is Python biased towards ISO-8859-1, although apparently MacPython defaults
>to interpreting text as MacRoman?

The only place where Python seems to care about the encoding at all are in
calls like string.lower() and string constants like string.letters.

>Indeed I'm willing to code the simple stuff I need but before I dig into it
>I thought I'd ask in the list first in case there already is a standardized
>way to do it (There's One Way To Do It (tm)).

Wait for Python 2.0 and you'll find all the encoding conversions you need,
thanks to the new Unicode support. Or play with the older 1.6 alpha's: it's
all in there.

>>> unicode("abcde", "macroman").encode("ISO-8859-1")
'abcde'
>>>

Just