On Tue, 2006-10-03 at 19:27 -0700, Beau Hartshorne wrote:
> On 3-Oct-06, at 6:56 PM, Malcolm Tredinnick wrote:
> 
> > This probably isn't going to solve your problem, but it might help  
> > track
> > down what is really happening...
> >
> > UnicodeDecodeError usually means that you are trying to use unicode
> > strings that haven't been converted to UTF-8 when they needed to be.
> > Django mostly "just works" if you pass around UTF-8 strings as strings
> > of bytes. It doesn't work entirely with native unicode objects
> > internally.
> >
> > So, I would check that you are really using UTF-8 bytes at that point.
> >
> > Could you maybe post the contents of "sql" and "params" when you  
> > get the
> > above error (post "params" in repr() format, not as a printed string,
> > since it's important to see the encoding, not just the output
> > character).
> 
> Hi Malcolm,
> 
> A repr() of 'Djangé' (from browser input) is 'Djang\xc3\xa9'.
> 
> I've checked that everything is set to UTF-8 (database defaults,  
> database tables, charset, html meta, django default). Should I  
> be .encode('utf8') any string I pass around, or am I doing something  
> else wrong?

So this is the value that the string has right at the moment the
exception occurs? Can you paste the traceback you see, please (and
preferably the value of 'sql' and 'params' at that point as well).

I'm a bit in the dark about what is happening right now, since
subsituting a UTF-8 string into a Python string should work easily.

        >>> s = unicode('Djang\xc3\xa9', 'utf-8')
        >>> print "update foo set blah = '%s'" % s
        update foo set blah = 'Djangé'

is an example of what should be happening. I suspect there is something
else important about what you are doing. Not accusing you of
deliberately misleading or anything -- I have no idea what the important
thing is yet, either.

Regards,
Malcolm


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to