Hello !
I don't know what is the best way to do that.
But this piece of code works well for me:
assert isinstance(source, str) # 'source' has to be a str
try:
good_utf8=source.decode('utf8')
except ValueError: # source is not utf8-coded
good_utf8=source.decode('iso8859-1') # Fallback on iso8859-1
> Hi guys!
>
> I want to know suggestion on how to convert a string to unicode... The
> gtk requires unicode strings on the widgets, now either I define the
> string as u'some string' or I define an attribute enconding
> (self.enc='iso8859-1') and for each string I use unicode(string,
> self.enc)... To access the string I use string.decode(self.enc)...
>
> Is this the best way to convert string to unicode?
>
> thanks for all help!
>
> =====
> --
> Michel Thadeu Sabchuk
> Curitiba/PR
>
> ______________________________________________________________________
>
> Yahoo! GeoCities: a maneira mais f�cil de criar seu web site gr�tis!
> http://br.geocities.yahoo.com/
> _______________________________________________
> pygtk mailing list [EMAIL PROTECTED]
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
>
>
Gabriel Ortega [EMAIL PROTECTED]
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/