string encoding problem

Rodolphe robloche at fr.st
Wed Nov 20 18:52:44 EST 2002


>> Could someone help me out with this simple problem ?
> 
> Tk is returning a Unicode object to you. If you want to write that
> Unicode object to a byte stream, you need to encode it, e.g. with
> 
>   print str.encode("cp1252")
> 
> Regards,
> Martin

Thanks.
Someone pointed me this useful link :

http://www.reportlab.com/i18n/python_unicode_tutorial.html


I found out the answer to my problem there.

Now, when Tk returns a string, say s, I use s.encode('latin-1') to take 
care of the accents.

Thanks to all of you !

--
Rodolphe



More information about the Python-list mailing list