Chewing international (unicode) filenames on windows?

Neil Hodgson nhodgson at bigpond.net.au
Tue Mar 19 03:39:17 EST 2002


Andrew Markebo:

> I am messing a bit with my bookmarks (gonna sync them between a bunch
> of computers and browsers) and now comes the question.. How does
> os.listdir in the windows-compiled python handle international
> characters?

   If the characters can not be represented in the current code page you get
'?' instead.

> But do we know that it is latin-1? How would we handle chineese
> characters? Someone said the filenames were unicoded, how do I
> encode/decode the filename som I can get it into UTF-8??

   PEP 277 looks at providing more Unicode file name support including
extending os.listdir to return Unicode strings.
http://python.sourceforge.net/peps/pep-0277.html
   Unfortunately, I haven't had time recently to push the PEP any further.
I'm also less certain of its cost / benefit ratio than I was initially as it
does complexify the Python library code a bit.

> p.s.2 what is the status on win9x? Give it up or ;-)

   More difficult as 9x doesn't have API support for retrieving the Unicode
names, so it could require reading the directory bytes directly.

   Neil






More information about the Python-list mailing list