[Issue 12897] New: std.json.toJSON doesn't translate unicode chars(>=0x80) to "\uXXXX"
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Thu Jun 12 04:48:10 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=12897
Issue ID: 12897
Summary: std.json.toJSON doesn't translate unicode
chars(>=0x80) to "\uXXXX"
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: critical
Priority: P1
Component: Phobos
Assignee: nobody at puremagic.com
Reporter: egustc at gmail.com
Created attachment 1362
--> https://issues.dlang.org/attachment.cgi?id=1362&action=edit
json bug
As the attachment showed, uUnicode chars GE than 0x80 (for exp.: Chinese,
Japanese ) should be converted to "\uXXXX" in JSON. But Phobos doesn't. It
causes problems while transmitting JSON from D to other languages.
A std.json.appendJSONChar implement can fix this bug:
private void appendJSONChar(Appender!string* dst, wchar c)
{
if(isControl(c) || c>=0x80)
dst.put("\\u%04x".format(c));
else
dst.put(c);
}
--
More information about the Digitalmars-d-bugs
mailing list