Unicode Decode Error

John Machin sjmachin at lexicon.net
Thu Apr 9 16:59:59 CEST 2009


On Apr 10, 12:40 am, MRAB <goo... at mrabarnett.plus.com> wrote:
> reetesh nigam wrote:
> > Hi All,
> > There is some special character in my database.
> > and when try to show on my UI it says
>
> >     return codecs.utf_8_decode(input, errors, True)
> > UnicodeDecodeError: 'utf8' codec can't decode byte 0xc4 in position
> > 10: unexpected end of data
>
> > Can any one help to solve this problem
>
> Perhaps it isn't valid UTF-8, but 8-bit characters in some encoding.

Or perhaps it is valid UTF-8, but the OP's code is picking up strg
[:nchars] instead of strg[:nbytes] or somehow otherwise separating the
two (or maybe even 3) bytes that UTF-8 needs to make up the character.

Perhaps the OP might
    print repr(all_the_undecoded_bytes_he_has)
then we might have a clue about how to give him a clue ...



More information about the Python-list mailing list