[Python-Dev] Unicode strings as filenames

M.-A. Lemburg mal@lemburg.com
Fri, 04 Jan 2002 12:11:12 +0100


"Martin v. Loewis" wrote:
> 
> > The only option I see to make this situation less painful is
> > to write a filename subsystem which implements two generic
> > APIs:
> >
> > 1. file open using strings and Unicode
> 
> I think this "pretty much" works in Python 2.2 already. It uses the
> "mbcs" encoding on Windows, and the locale's encoding on Unix if
> locale.setlocale has been called (and the C library is good enough).
> 
> That might be still wrong if the file system expects UTF-8, or a fixed
> encoding (e.g. on an NTFS or VFAT partition mounted on Linux), but I
> don't think there is anything that can be done about this: It would be
> a misconfigured system if then the user doesn't also use an UTF-8
> locale.

We'd still need to support other OSes as well, though, and I
don't think that putting all this code into fileobject.c is
a good idea -- after all opening files is needed by some other
parts of Python as well and may also be useful for extensions.

I'd suggest to implement something similiar to the DLL loading
code which is also implemented as subsystem in Python.
 
> > 2. file listing using either Unicode or strings with a predefined
> >    encoding in the output list
> 
> That is something that certainly needs to be done. Having a PEP on
> that would be useful.

Yep.

-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
______________________________________________________________________
Company & Consulting:                           http://www.egenix.com/
Python Software:                   http://www.egenix.com/files/python/