[Tutor] latin-1 to unicode in python
Kent Johnson
kent37 at tds.net
Wed Aug 2 22:54:54 CEST 2006
anil maran wrote:
> 'ascii' codec can't encode character u'\x96' in position 213: ordinal
> not in range(128)
>
> now i m getting this error
Please show your code and the traceback and reply on list, not to me
personally.
Kent
>
> */Kent Johnson <kent37 at tds.net>/* wrote:
>
> anil maran wrote:
> > Unicode?
> > im getting this error:
> > invalid byte sequence for encoding "UTF8": 0x92
> >
> > since the db is not handling latin-1 and is set to use UTF8 how
> do i
> > handle this
>
> If you have a latin-1 string and you want utf-8, convert it to
> Unicode
> and then to utf-8 using decode() and encode():
>
> In [1]: s='\x92'
>
> In [3]: s.decode('latin-1').encode('utf-8')
> Out[3]: '\xc2\x92'
>
> Kent
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
> ------------------------------------------------------------------------
> Do you Yahoo!?
> Get on board. You're invited
> <http://us.rd.yahoo.com/evt=40791/*http://advision.webevents.yahoo.com/handraisers>
> to try the new Yahoo! Mail Beta.
More information about the Tutor
mailing list