[Tutor] UTF-8 filenames encountered in os.walk

William O'Higgins Witteman hmm at woolgathering.cx
Tue Jul 3 17:57:03 CEST 2007

I have several programs which traverse a Windows filesystem with French
characters in the filenames.

I have having trouble dealing with these filenames when outputting these
paths to an XML file - I get UnicodeDecodeError: 'ascii' codec can't
decode byte 0xe9 ... etc.  That happens when I try to convert to UTF-8.

I know what os will give me UFT-8 if I give it UTF-8, and I am trying to
do that, but somewhere down the line it seems like it reverts to ASCII,
and then I get these errors.

Has anyone found a silver bullet for ensuring that all the filenames
encountered by os.walk are treated as UTF-8?  Thanks.



More information about the Tutor mailing list