[Python-Dev] Unicode strings as filenames
Martin v. Loewis
martin@v.loewis.de
Thu, 3 Jan 2002 23:09:57 +0100
> On Windows NT/2K/XP the right thing to do is to use the wide char open
> function such as
> _CRTIMP FILE * __cdecl _wfopen(const wchar_t *, const wchar_t *);
> _CRTIMP int __cdecl _wopen(const wchar_t *, int, ...);
I agree. However:
- Mark decided to take a different route, using fopen all the time, but
encoding Unicode strings with the "mbcs" encoding, which calls
MultiByteToWideCharCP with CP_ACP. AFAICT, this is correct as well
(although it invokes an unneeded conversion of the string, since
fopen, eventually, will convert the string back to Unicode - probably
inside CreateFileExA - atleast on WinNT).
In any case, passing Unicode objects to open() works just fine, atleast
as long as they can be encoded in the ANSI code page. If you want to
open a Chinese file name on a Russian Windows installation, you lose.
- Skip was likely asking about a Unix installation, in which case all
of this is irrelevant.
> There may also be techniques for doing this on Windows 9x as the file
> system stores Unicode file names but I have never looked into this.
To my knowledge, VFAT32 doesn't - only NTFS does (which is not
available on W9x).
Regards,
Martin