Filename encoding on XP

"Martin v. Löwis" martin at v.loewis.de
Wed Jan 3 10:50:36 EST 2007


kent sin schrieb:
> What encoding does the NTFS store the filename?

In UTF-16LE. However, on-disk storage is mostly irrelevant, what
matters is what encoding is used on the OS API.

Windows has two forms of file API: Wide (Unicode) and ANSI
(byte-oriented). On NT, the Wide API is "native"; the ANSI API
converts strings forth and back (introducing ? if the conversion
fails).

> I use walk, then print the filename, there are some ? in it, but some
> Chinese characters were display with no problem. I suspect the
> encoding of the filename is not unicode. 

You need to pass a Unicode string into walk as the directory; then
recursively all results should also be Unicode strings.

Regards,
Martin





More information about the Python-list mailing list