You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
dump's parameter "ensure_ascii" creates too long sequences #656
The code seems to created too long \uxxxx sequences. Take the € sign for instance. It is U+20AC and should be encoded as string "\u20ac". The current code encodes it as "\u00e2\u0082\u00ac". This is incorrect, as this does not roundtrip.
We basically need a conversion from UTF-8 encoded chars to the Unicode codepoint and then use the existing escaping if the codepoint is 0..127 and UTF-16 hex(es) otherwise.
No worries. I used the all_unicode.json file, created a serialization in Python with the ensure_ascii parameter and compared the output with the library's dump output.
Activity
nlohmann commentedon Jul 12, 2017
Example in Python:
Output:
nlohmann commentedon Jul 12, 2017
We basically need a conversion from UTF-8 encoded chars to the Unicode codepoint and then use the existing escaping if the codepoint is 0..127 and UTF-16 hex(es) otherwise.
ryanjmulder commentedon Jul 12, 2017
yup, I agree. Sorry about the bug, my mistake.
nlohmann commentedon Jul 12, 2017
No worries. I used the all_unicode.json file, created a serialization in Python with the
ensure_asciiparameter and compared the output with the library'sdumpoutput.Any help appreciated - I'm going to bed now ;)
🐛 fix for #656
nlohmann commentedon Jul 17, 2017
I rewrote the escaping code. @ryanjmulder - if you can find the time, I would be happy if you could have a look at the diff.