[Issue 17556] New: std.json encodes non-BMP characters incorrectly with JSONOptions.escapeNonAsciiChars
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Jun 26 01:33:42 PDT 2017
https://issues.dlang.org/show_bug.cgi?id=17556
Issue ID: 17556
Summary: std.json encodes non-BMP characters incorrectly with
JSONOptions.escapeNonAsciiChars
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P3
Component: phobos
Assignee: nobody at puremagic.com
Reporter: dlang-bugzilla at thecybershadow.net
/////////////////// test.d ///////////////////
import std.json;
import std.stdio;
void main()
{
auto v = JSONValue("\U0001D11E");
writeln(toJSON(v, false,
JSONOptions.escapeNonAsciiChars));
}
//////////////////////////////////////////////
Above program prints "\uD11E", which is not the correct character.
Non-BMP characters should be encoded as a pair of escaped UTF-16 surrogate
pairs, as per RFC 4627.
See also issue 5904.
--
More information about the Digitalmars-d-bugs
mailing list