Chewing international (unicode) filenames on windows?
Mark Hammond
mhammond at skippinet.com.au
Tue Mar 19 06:25:47 EST 2002
Andrew Markebo wrote:
> | > For me on my windows 2000 machine, to get them into UTF-8 format I do
> | > something like:
> | > for filename in os.listdir():
> | > utffilename=unicode(filename, "latin-1").encode("utf-8")
> |
> | utffilename=unicode(filename, "mbcs").encode("utf-8")
>
> Hello!
>
> So do I get it right now, reading it as mbcs ("Multibyte-character")
> will read all ntfs filenames correctly (as unicode defines it) into a
> unicode string?
This will work as long as the filename can be represented in your
current code page. If not, you will get a '?'. Other comments in this
thread point to a proposal to use Unicode objects making every file
available regardless of your codepage.
> | > p.s.2 what is the status on win9x? Give it up or ;-)
> |
> | I *think* it still works when accessing a Unicode aware file system
> | (ie, network)
>
> What I want is to read a local file-name on a win9x fat/fat32 disk and
> be able to convert it into unicode.. And the other way around.
>
> I will probably add a if windows9x do that, else if win2k do
> this.. ;-) Hmm how do I determine windows-version?
win32api.GetVersion(Ex)
Mark.
More information about the Python-list
mailing list