convert utf-8 to latin-1?

"Martin v. Löwis" martin at v.loewis.de
Fri Feb 6 02:03:40 EST 2004


Uwe Mayer wrote:

> 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. 

Try converting the object to a Unicode object. I don't know what you
mean by "utf-8 string object"; Python has no such thing (but PyQt may).

Then, pass the unicode object to open().

> So my first question is wether you *can* convert it without loosing
> something and secondly: how?

In Python 2.3, you best use unicode strings to represent file names;
Python should know how to map them to the local representation,
depending on operating system conventions.

Regards,
Martin




More information about the Python-list mailing list