I also occasionally get UnicodeDecodeError's. Right now I'm getting a
traceback when posting a form in the admin area. Everything works
perfectly when the form does not contain any non-ascii letters, but
when it does, it gives me a traceback (http://dpaste.com/69963/). I
have existing model objects in the database whose charfields contain
unicode data and they display just fine. It's just when I save unicode
data that I get this error. The error occurs before any SQL UPDATE
statements because the object isn't modified.
Erik
Hey,
I also occasionally get UnicodeDecodeError's. Right now I'm getting a
traceback when posting a form in the admin area. Everything works
perfectly when the form does not contain any non-ascii letters, but
when it does, it gives me a traceback (http://dpaste.com/69963/). I
have existing model objects in the database whose charfields contain
unicode data and they display just fine. It's just when I save unicode
data that I get this error. The error occurs before any SQL UPDATE
statements because the object isn't modified.
On 07.08.2008, at 10:28, Julien Phalip wrote:
>
> Hi,
>
> There is a recurrent problem that I can never get my head around,
> probably because of my limited understanding of how unicode works.
>
> There is some text fetched from the database that I try to convert to
> unicode, using force_unicode, before processing it further. It
> generally works but occasionally it chokes with some special
> characters. The type of errors I get is like the following:
>
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xe5' in
> position 15: ordinal not in range(128)
>
> Before it was ported to MySQL, the database was made with MS Access.
> Therefore some text contains microsoft-proprietary encoding stuff,
> which I try to go around with the following:
>
> try:
> encoded_item = force_unicode(item, "utf-8")
> except UnicodeDecodeError:
> encoded_item = force_unicode(item, "cp1252")
>
> Anyway, I don't know how to deal with those UnicodeEncodeError, and
> I'd appreciate any pointers or hints to help me fix it. Any idea?
>
Thanks for the reply, Karen!Does anyone know of a workaround until it gets fixed? It's really a blocker right now.