Best way to convert string a to utf-*

Erik Max Francis max at alcyone.com
Fri Mar 19 04:50:55 EST 2004


Oliver Kurz wrote:

> could someone tell me the best way to convert a string to utf, for
> example
> to utf-8?
> 
> The problem: I have no controll about the source where the string
> comes
> from. It could have any possible characterset. And I have to convert
> it for
> example to utf-8.

If the format is not already a Unicode string, you really can't know
what encoding it's in.  To convert it to UTF-8 (or UTF-16 or UTF-32),
you really must know what format it's in to begin with or otherwise
you're stuck.

-- 
 __ Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
/  \ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
\__/ He who conceals his disease cannot expect to be cured.
    -- (an Ethiopian proverb)



More information about the Python-list mailing list