[I18n-sig] Passing unicode strings to file system calls

M.-A. Lemburg mal@lemburg.com
Wed, 17 Jul 2002 22:23:54 +0200


Martin v. Loewis wrote:
> "M.-A. Lemburg" <mal@lemburg.com> writes:
> 
> 
>>You mean: call setlocale() to set something or fetch the
>>encoding from it ? Setting a locale to something other than
>>"C" will cause quite a few semantic changes, so you should
>>beware...
> 
> 
> Indeed. However, setting the locale may be the only way to find out
> what the locale's encoding is.
> 
> 
>>Note there's also locale.getdefaultlocale()
> 
> 
> That is broken beyond repair, and should not be used for anything. It
> can't possibly work.

Hmm, why is that ?

>>which work on many platforms and returns the default locale and
>>encoding for the platform Python currently runs on.
> 
> 
> In particular when it comes to the locale's encoding, it has no chance
> to work correctly, except on Windows.

There's a large database in locale.py for this and a few
support APIs which make use of it.

It would probably be
worthwhile to add an interface encoding(localename)
which only returns the encoding used per default for
that locale.

-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
_______________________________________________________________________
eGenix.com -- Makers of the Python mx Extensions: mxDateTime,mxODBC,...
Python Consulting:                               http://www.egenix.com/
Python Software:                    http://www.egenix.com/files/python/