how to find out utf or not

Gisle Vanem gvanem at
Tue Nov 5 18:10:16 CET 2013

"Steven D'Aprano" <steve+comp.lang.python at> wrote:

> If myVar is a Unicode string, you don't need to care about the encoding 
> (UTF-8 or otherwise) until you're ready to write it to a file. Then I 
> strongly recommend you always use UTF-8, unless you have to interoperate 
> with some old, legacy system:
> assert isinstance(myVar, unicode)
> byte_string = myVar.encode('utf-8')

An excellent summary of the mystics around text-encoding. Thank you.


More information about the Python-list mailing list