On 28.11.20 15:21, frame wrote:
This throws an UTF-exception:

auto json = JSONValue(cast(char[])[0x00, 0x7D, 0xFE, 0xFF, 0x14, 0x32, 0x43, 0x10]);
writeln(json.toString(JSONOptions.escapeNonAsciiChars));

Makes no sense. Either the bytes should be properly escaped or there should not be any option if a string want to be converted to UTF anyway.

Makes perfect sense. The option is called "escapeNonAsciiChars", not "escapeNonUnicodeChars".

This is also fun:

auto json = JSONValue(r"\u0000\u007D\u00FE\u00FF\u0014\u0032\u0043\u0010");
assert(json.toString() == json.toString(JSONOptions.doNotEscapeSlashes));

and ends with:

"\\u0000\\u007D\\u00FE\\u00FF\\u0014\\u0032\\u0043\\u0010"

This is a slash: /
This is a backslash: \

There are no slashes in your string.

Reply via email to