On 24 Jul 2006, at 12:21, patrickk wrote:

> has anyone ever used simplejson with umlauts?
> I´m reading a title from a blog-entry which has umlauts and they are
> not displayed correctly.

I doubt this is a problem with simplejson; it seems to handle unicode  
characters just fine. I imagine you are passing it a utf-8 encoded  
Python bytestring without it knowing what the encoding is. You need  
to pass it a proper unicode string - try something like this:

 >>> s = 'r\xc3\xb6ck d\xc3\xb6ts' # A utf-8 encoded bytestring
 >>> u = s.decode('utf-8') # u is now a unicode string
 >>> print simplejson.dumps(u)
"r\u00f6ck d\u00f6ts"

That last line is the correct way of representing unicode in JSON. If  
you paste that in to Firebug it renders as "röck döts".

Hope that helps,

Simon



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to