Python and UTF-8
Martin v. Loewis
martin at v.loewis.de
Wed Jan 2 16:28:47 EST 2002
Brandvik <tmagna at online.no> writes:
> Is it possible to make a python script that would change the character
> to UTF-8 no matter what the encoding of the input is? I have heard
> that Python has some great functions for Unicode formatting so this
> might be an easy and trivial task, but I'm new to Python so I really
> don't know...
You have to know the encoding the data is currently, say
current_encoding. Then, converting it into UTF-8, you write
data = unicode(data, current_encoding).encode('utf-8')
HTH,
Martin
More information about the Python-list
mailing list