www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17556] New: std.json encodes non-BMP characters incorrectly


          Issue ID: 17556
           Summary: std.json encodes non-BMP characters incorrectly with
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P3
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: dlang-bugzilla thecybershadow.net

/////////////////// test.d ///////////////////
import std.json;
import std.stdio;

void main()
    auto v = JSONValue("\U0001D11E");
    writeln(toJSON(v, false,

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.

Jun 26 2017