Strange problems with encoding

Fredrik Lundh fredrik at
Thu Nov 6 18:07:38 CET 2003

Rudy Schockaert wrote:

> At the end of you can enable a piece of code that sets your
> default encoding to the current locale of your computer:
> if 1:
>      # Enable to support locale aware default string encodings.
>      import locale
>      loc = locale.getdefaultlocale()
>      if loc[1]:
>          encoding = loc[1]
> This works great for me.

instead of hacking your Python installation, I suggest using
explicit calls to the "encode" method wherever you need to
convert from Unicode to binary data on the way out.

> P.S. I really need some weeks off so I can read all the available
> documentation ;-)

it shouldn't take you more than 15-20 minutes to learn enough
about Unicode to be able to write Python code that processes
non-ASCII text in a reliable and portable way:

short version:

long version:


More information about the Python-list mailing list