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

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

Description

@GoogleCodeExporter
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 jens.lun...@a-b-i.se on 14 Nov 2011 at 8:34

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions