Neslib.Json icon indicating copy to clipboard operation
Neslib.Json copied to clipboard

Problem with stringifying a JSON string consisting of Chinese characters

Open MAC420965 opened this issue 3 years ago • 0 comments

The following code fails in a Delphi 11.1/Windows 64 Bit application with the conditional JSON_UTF8 defined in the Neslib.Json.* units:

program jsonwriter_err;

{$APPTYPE CONSOLE}

{$R *.res}

uses System.SysUtils, Neslib.Json;

var doc: IJsonDocument; s1, s2: utf8string;

begin s1 := '{"s":"クランクケース/全面カバー"}'; doc := TJsonDocument.Parse(s1); s2 := doc.Root.ToJson(false); WriteLn(Utf8ToString(s2)); ReadLn; end.

Call stack:

:00007FFD1609CD29 ; C:\WINDOWS\System32\KERNELBASE.dll System._RaiseAtExcept(???,???) System.SysUtils.AssertErrorHandler('Assertion fehlgeschlagen','... Neslib.Json.IO.pas',1586,$712F5D) System._Assert(???,???,???) Neslib.Json.IO.TJsonWriter.WriteEscapedString('クランクケース/全面カバー') Neslib.Json.IO.TJsonWriter.WriteString('クランクケース/全面カバー') Neslib.Json.TJsonValue.WriteTo(TJsonWriter($258AEED80A0) as IJsonWriter) Neslib.Json.TJsonValue.TJsonDictionary.WriteTo(TJsonWriter($258AEED80A0) as IJsonWriter) Neslib.Json.TJsonValue.WriteTo(TJsonWriter($258AEED80A0) as IJsonWriter) Neslib.Json.TJsonValue.ToJson(False)

MAC420965 avatar Nov 03 '22 19:11 MAC420965