pep 277, Unicode filenames & mbcs encoding &c.

vincent wehren vincent at
Tue Oct 21 17:31:04 CEST 2003

"Edward K. Ream" <edreamleo at> schrieb im Newsbeitrag
news:vpagr71f8fudc7 at
| Am I reading pep 277 correctly?  On Windows NT/XP, should filenames always
| be converted to Unicode using the mbcs encoding?  For example,
| myFile = unicode(__file__, "mbcs", "strict")

No and no. You can *still* use regular byte strings. Python will do the
conversion to Unicode for you using "mbcs" as encoding.

| This seems to work, and I'm wondering whether there are any other details
| consider.
| My experiments with Idle for Python 2.2 indicate that os.path.join doesn't
| work as I expect when one of the args is a Unicode string.  Everything
| before the Unicode string gets thrown away.  But this is probably moot:
| 277 implies Python 2.3...

Exactly. Python Unicode file name support has arrived with 2.3.

| Are there any situations where some other encoding should be used instead
| Windows?  What about other platforms? For instance, does Linux allow
| non-ascii file names?

You can use "os.path.supports_unicode_filenames" to check...


Vincent Wehren

If so, what encoding should be specified when
| converting to Unicode?  Thanks.
Propably the default encoding, on Linux

| Edward
| --------------------------------------------------------------------
| Edward K. Ream   email:  edreamleo at
| Leo: Literate Editor with Outlines
| Leo:
| --------------------------------------------------------------------

More information about the Python-list mailing list