Skip to content

UltraJson doesn't behave the same way as json.JSONEncoder for unicode chars #156

@prosanes

Description

@prosanes

As stated in issue #155:

I'm not sure that ujson.encode('\ud83d\ude80') should give any error.
The Python standard json library ("simplejson") doesn't:

json.JSONEncoder().encode('\ud83d\ude80')
'"\ud83d\ude80"'

When using ujson:

Python 3.3.2 (default, Sep 16 2013, 16:19:35)
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ujson
>>> ujson.encode('\ud83d\ude80')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'utf-8' codec can't encode character '\ud83d' in position 0: surrogates not allowed
>>> ujson.__version__
'1.34'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions