convert utf-8 to latin-1?
Markus Faltin
marfal at gmx.de
Thu Feb 5 14:10:53 EST 2004
Uwe Mayer wrote:
> in a PyQt application I'm writing, the user can select a filename with a
> FileDialog. Then I would like to open this file. This works fine if there
> are no "special symbols" in the filename, such as the german umlauts: "ÖÄÜ"
>
> Currently I convert the returned, of what I'm pretty sure its a utf-8 string
> object, to a normal string using the str() function. But then my string
> contains garbage and I cannot find that file on my ext3 fs (which uses
> latin-1).
Decode the string to unicode and then encode it to latin-1:
>>> filename_latin1 = unicode(filename_utf8, 'utf-8').encode('latin-1')
Markus
More information about the Python-list
mailing list