[Issue 17553] New: std.json invalid utf8 sequence

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Jun 25 10:54:08 PDT 2017


https://issues.dlang.org/show_bug.cgi?id=17553

          Issue ID: 17553
           Summary: std.json invalid utf8 sequence
           Product: D
           Version: D2
          Hardware: x86
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: andre at s-e-a-p.de

It is possible to read a file into a string. JSONValue happily accepts this
string which contains binary data.
But the moment you want to get data using js.toString an exception is thrown:
core.exception.UnicodeException at src\rt\util\utf.d(292): invalid UTF-8 sequence



import std.json;
import std.file: read;

void main()
{
    string s = cast(string) read(`C:\D\dmd2\windows\bin\dmd.exe`);
    JSONValue js = JSONValue(s);

    string s2 = js.toString; // this line will throw the exception
}

--


More information about the Digitalmars-d-bugs mailing list