You are not logged in.
Pages: 1
Hi,
do you can try r := JSONEncode(['t','test "" again ""']);
Result: {"t":"text \"" again ""\" again \""\""}
Fast Patch (inserted line // mapes):
procedure TTextWriter.AddJSONEscapeW(P: PWord; Len: PtrInt);
var i,c,s: PtrInt;
esc: byte;
begin
if P=nil then
exit;
if Len=0 then
Len := MaxInt;
i := 0;
while i<Len do begin
s := i;
repeat
c := PWordArray(P)[i];
if (c<=127) and (JSON_ESCAPE[c]<>0) then
break;
inc(i);
until i>=Len;
if i <> s then // mapes
AddNoJSONEscapeW(@PWordArray(P)[s],i-s);
if i>=Len then
exit;
c := PWordArray(P)[i];
if c=0 then
exit;
esc := JSON_ESCAPE[c];
if esc=1 then // #0
exit else
if esc=2 then begin // characters below ' ', #7 e.g. -> \u0007
AddShort('\u00');
AddByteToHex(c);
end else
Add('\',AnsiChar(esc)); // escaped as \ + b,t,n,f,r,\,"
inc(i);
end;
end;
Offline
Please check https://synopse.info/fossil/info/f06626ecbf
Thanks for the feedback!
Offline
Pages: 1