os.lisdir, gets unicode, returns unicode... USUALLY?!?!?

Leo Kislov Leo.Kislov at gmail.com
Tue Nov 21 05:25:35 EST 2006


Ross Ridge wrote:
> > > That's the problem here, there's no
> > > encoding associated Unix filenames, they're just byte strings.
> >
> > Can you please quote chapter and verse of the POSIX spec that says
> > so?
>
> I said Unix, not POSIX.  In practice, Unix systems don't associate an
> encoding with filenames, and any byte value other than '/' or '\0' is
> permitted in a filename.

But that doesn't mean you should store pictures in file names. File
names are supposed to be human readable text labels for binary files.
Most UNIX-like distributions and admins that *care* about multilingual
support setup systems properly, *all* file names within local network
use the same encoding. In those situations when systems are
misconfigured, you can ask user what is the encoding, for example
through locale setting: I can go to a misconfigured windows share and
type "LANG=ru_RU.cp1251 ls" to correctly display Russian file names.

  -- Leo




More information about the Python-list mailing list