Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

UnicodeEncodeError model field returns unicode and not UTF-8 #19

Open
GoogleCodeExporter opened this issue Mar 16, 2015 · 11 comments
Open

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?

1. use wad serializer in Py2.7 and Dj1.3, serializing model with e.g. field 
'name' which has value that is beyond ascii (e.g. name = u'täst'), have 
ensure_ascii=False

2. When serializing (ensure_ascii=False) you then get 'ascii' codec can't 
encode characters in position 9-10: ordinal not in range(128) in self.end and 
doing simplejson.dump

3. poof...

What is the expected output? 
Was expecting to see field correctly encoded in json string in UTF-8. u'täst' 
should be 't\xc3\xa4st'

What do you see instead?
 It is a normal python unicode string e.g. u'täst' or u't\xe4st', this is not UTF-8 so the error is correct but wrong ;-)


What version of the product are you using? On what operating system? Mac 
10.7.2, Py2.7, Django 1.3

Please provide any additional information below.

Did set ensure_ascii to True, then it returns correctly but the resulting JSON 
shown has name=u't\xe4st', i.e. the string is not utf-8 encoded.

Original issue reported on code.google.com by [email protected] on 14 Nov 2011 at 8:34

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant