How to decode a string

Lad python at hope.cz
Mon Aug 21 11:49:45 EDT 2006


Fredrik Lundh wrote:
> Lad wrote:
>
> > To be able to decode a string successfully, I need to know what coding
> > it is in.
>
> ask whoever provided the string.
>
> > The string can be coded in utf8 or in windows-1250 or in another
> > coding.  Is there a method how to find out the string coding.
>
> in general, no.  if you have enough text, you may guess, but the right
> approach for that depends on the application.
>
> </F>
Fredrik,
Thank you for your reply
The text is from Mysql table field that uses utf8_czech_ci collation,
but when I try
`RealName`.decode('utf8'),where RealName is that  field of MySQL

I will get:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 3:
ordinal
not in range(128)

Can you please suggest the solution?
Thank you 
L.




More information about the Python-list mailing list