character encoding conversion

Christian Ergh christian.ergh at
Mon Dec 13 11:35:25 CET 2004

- snip -
> def get_encoded(st, encodings):
>     "Returns an encoding that doesn't fail"
>     for encoding in encodings:
>         try:
>             st_encoded = st.decode(encoding)
>             return st_encoded, encoding
>         except UnicodeError:
>             pass
This works fine, but after this you have three possible encodings (or 
even more, looking at the data in the net you'll see a lot of 
encodings...)- what we need is just one for all.

More information about the Python-list mailing list