Hey Jeremy,

On Fri, 2007-05-04 at 19:44 -0500, Jeremy Dunck wrote:
> Malcolm,
>   I noticed that Django's current serialization doesn't deal with unicode 
> well.

Too true. :-)

> 
>   When using MySQLdb with utf8 as the encoding, charfields return
> unicode objects.  base.get_string_field breaks because it calls str()
> on the field, forcing python to use sys.getdefaultencoding().
> 
>   As a result, the XML serializer dies.  The (default) json serializer
> sidesteps the issue by using ensure_ascii, which escapes unicode using
> \uXXXX notation.
> 
>   I did a minimal patch to make unicode serialization work for me, but
> I think this is an area that needs some love on the unicode branch.
> My patch probly isn't a reasonable solution in general.

It's on the list
(http://code.djangoproject.com/wiki/UnicodeBranch#TodoItems ).

Hmm... I need to update that page with the current status.


>   Another issue is that mysql requires "utf8" as the encoding string,
> but python's SAX parser requires "utf-8", so that writing a file
> (using DEFAULT_CHARSET='utf8' (with my patch) works, but I have to
> hand-edit the encoding declaration to 'utf-8' to make SAX happy.

Thanks for thinking this through a bit. It's always good to have another
person's ideas to sanity check what I'm thinking of doing. I genuinely
haven't looked at the serialisation code yet, but it's getting close now
(form processing will go in today or tomorrow and syndication and
serialization are next). I'll keep this email around when I work on
that.

Regards,
Malcolm


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

Reply via email to