How do I obtain the filenames' encoding after os.listdir?

Moshe Zadka m at moshez.org
Wed Jun 4 06:43:20 EDT 2003


On Wed, 4 Jun 2003, Grzegorz Adam Hankiewicz <gradha at titanium.sabren.com> wrote:

> I want to transform the strings to unicode objects so I can use them
> with pygtk, and the current process works ok for my machine. The
> question is how do I know the encoding of the filenames?  Currently
> I'm presuming latin1, but if somebody else uses a different encoding,
> how do I know which one?

Indeed how? Filenames, in UNIX, are just byte-streams (where the only
rule is that "/" and "\0" can't appear). There is no information about
encoding, so any information will be, of necessity, application-specific
and out-of-band.
-- 
Moshe Zadka -- http://moshez.org/
Buffy: I don't like you hanging out with someone that... short.
Riley: Yeah, a lot of young people nowadays are experimenting with shortness.
Agile Programming Language -- http://www.python.org/





More information about the Python-list mailing list