pep 277, Unicode filenames & mbcs encoding &c.

Martin v. Löwis martin at v.loewis.de
Thu Oct 23 02:16:35 EDT 2003


"Edward K. Ream" <edreamleo at charter.net> writes:

> if fileName1 == fileName2:
> 
> where one fileName is a unicode string and the other isn't yet.  That's why
> I wanted to do:
> 
> myFile = unicode(__file__, "mbcs", "strict")

Ah, I see. Instead of "mbcs", you should use
sys.getfilesystemencoding(). This is what Python will use when
converting the Unicode strings back to byte strings before passing
them to the system (in case it converts back at all, which it doesn't
on Windows thanks to PEP 277).

Regards,
Martin




More information about the Python-list mailing list