How do I obtain the filenames' encoding after os.listdir?
Grzegorz Adam Hankiewicz
gradha at titanium.sabren.com
Wed Jun 4 11:50:03 CEST 2003
I'm using os.listdir() to read a directory. The function returns
a list of string objects:
In : l = os.listdir(".")
In : l
In : l.decode("latin1")
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?
The documentation says string.decode can use as parameter "ignore"
or "replace", but using them only raises LookupErrors.
Please don't send me private copies of your public answers. Thanks.
More information about the Python-list