UTF8 error

32 views
Skip to first unread message

Jose Galvez

unread,
Mar 24, 2007, 3:45:42 AM3/24/07
to pylons
Hi all,

I'm hopping someone an give me a clue about how to handle this problem.
I've got an application that gets data from a database and basically
feeds the data to another program via json. I just started getting this
error:

<type 'exceptions.UnicodeDecodeError'>: 'utf8' codec can't decode byte
0x92 in position 247: unexpected code byte

I think that means that I've got some kind of funky code (I don't know
what 0x92 would be) in my database. Does anyone know how to get around
this?

Thanks in advance for any and all help
Jose

Luis Miguel Morillas

unread,
Mar 24, 2007, 5:46:03 AM3/24/07
to pylons-...@googlegroups.com
2007/3/24, Jose Galvez <jj.g...@gmail.com>:

>
> Hi all,
>
> I'm hopping someone an give me a clue about how to handle this problem.
> I've got an application that gets data from a database and basically
> feeds the data to another program via json. I just started getting this
> error:
>
> <type 'exceptions.UnicodeDecodeError'>: 'utf8' codec can't decode byte
> 0x92 in position 247: unexpected code byte
>
Are you on windows?

>>> import unicodedata
>>> unicodedata.name(unicode('\x92', 'cp1252'))
'RIGHT SINGLE QUOTATION MARK'

>>> print unicode('\x92', 'cp1252')
'

> I think that means that I've got some kind of funky code (I don't know
> what 0x92 would be) in my database. Does anyone know how to get around
> this?
>
> Thanks in advance for any and all help
> Jose
>
> >
>


--
Saludos,

--

Luis Miguel

Jose Galvez

unread,
Mar 24, 2007, 1:45:45 PM3/24/07
to pylons-...@googlegroups.com
yep I'm on windows.

So if I get the code below, unicodedata.name will tell me what the
character actually is, so how do I fix it so that I can actually print
it? Right now I'm trying to replace \x92 with ' but that looks
fragile. Does anyone know if there is a more generic way of doing this?
Jose

Luis Miguel Morillas

unread,
Mar 24, 2007, 2:58:40 PM3/24/07
to pylons-...@googlegroups.com
2007/3/24, Jose Galvez <jj.g...@gmail.com>:

>
> yep I'm on windows.
>
> So if I get the code below, unicodedata.name will tell me what the
> character actually is, so how do I fix it so that I can actually print
> it? Right now I'm trying to replace \x92 with ' but that looks
> fragile. Does anyone know if there is a more generic way of doing this?
> Jose
>

Yes, you must configure your app. Do you understand unicode? Read
http://www.amk.ca/python/howto/unicode or
http://effbot.org/zone/unicode-objects.htm.


> Luis Miguel Morillas wrote:
> > 2007/3/24, Jose Galvez <jj.g...@gmail.com>:
> >
> >> Hi all,
> >>
> >> I'm hopping someone an give me a clue about how to handle this problem.
> >> I've got an application that gets data from a database and basically
> >> feeds the data to another program via json. I just started getting this
> >> error:
> >>
> >> <type 'exceptions.UnicodeDecodeError'>: 'utf8' codec can't decode byte
> >> 0x92 in position 247: unexpected code byte
> >>
> >>
> > Are you on windows?
> >
> >
> >>>> import unicodedata
> >>>> unicodedata.name(unicode('\x92', 'cp1252'))
> >>>>
> > 'RIGHT SINGLE QUOTATION MARK'
> >
> >
> >>>> print unicode('\x92', 'cp1252')
> >>>>
> > '
> >
> >
> >> I think that means that I've got some kind of funky code (I don't know
> >> what 0x92 would be) in my database. Does anyone know how to get around
> >> this?
> >>
> >> Thanks in advance for any and all help
> >> Jose
> >>
> >>
> >
> >
> >
>
>
> >
>

Jose Galvez

unread,
Mar 24, 2007, 8:21:20 PM3/24/07
to pylons-...@googlegroups.com
Thanks for the links, I've never done much with unicode so no I'm not
that familiar with it. In any event, thanks again for the links I'll do
some reading
Jose

Jose Galvez

unread,
Mar 25, 2007, 1:49:18 AM3/25/07
to pylons-...@googlegroups.com
Thanks for the links Luis, they were very helpful and I got my code
cleaned up
Jose
Reply all
Reply to author
Forward
0 new messages