Unicode entries on sys.path
vincent at visualtrans.de
Fri Dec 24 13:50:44 CET 2004
> In article <41CB0D7A.3080107 at v.loewis.de>,
> "Martin v. Lowis" <martin at v.loewis.de> wrote:
>>>Hm, maybe more a windows question than a python question...
>>The real question here is: why does Python not support arbitrary
>>Unicode strings on sys.path? It could, in principle, atleast on
>>Windows NT+ (and also on OSX). Patches are welcome.
> Works for me on OSX 10.3.6, as it should: prior to using the sys.path
> entry, a unicode string is encoded with Py_FileSystemDefaultEncoding.
For this conversion "mbcs" will be used on Windows machines, implying
that such conversions are made using the current system Ansi codepage.
(As a matter of interest: What is this on OSX?). This conversion is
likely to be useless for unicode directory names containing characters
that do not have a mapping to a character in this particular codepage.
The technique described by Martin may solve the problem for what in this
case are Japanese characters, but what if I have directory names from
another language group, such as simpliefied Chinese, as well?
The only way to get around this is to allow - as Martin suggests -
arbitrary unicode strings in sys.path on those platforms that may have
unicode file names.
> I'm not sure how well it works together with zipimport, though.
More information about the Python-list