hydrobyte / McJSON

A Delphi / Lazarus / C++Builder simple and small class for fast JSON parsing.
MIT License
58 stars 20 forks source link

McJSONEscapeString TAB problem #21

Closed totyaxy closed 1 year ago

totyaxy commented 1 year ago

Hi!

I'v found small error in the new function:

procedure TForm1.Button1Click(Sender: TObject);
const
  cSample = 'Fisch'+#9;
var
  s: string;
begin
  s := McJSONEscapeString(cSample, jetNormal);
  Memo1.Lines.Add('MC: "'+s+'"');
  s := McJSONUnEscapeString(s);
  if s <> cSample then Memo1.Lines.Add('MC error!')
  else Memo1.Lines.Add('MC OK!');

  s := StringToJSONString(cSample);
  Memo1.Lines.Add('FP: "'+s+'"');
  s := JSONStringToString(s);
  if s <> cSample then Memo1.Lines.Add('FP error!')
  else Memo1.Lines.Add('FP OK!');
end;      

Result:

Memo1
MC: "Fisch\ "
MC error!
FP: "Fisch\t"
FP OK!
hydrobyte commented 1 year ago

Hi,

Thanks for sharing it. I've just commit a fix.

totyaxy commented 1 year ago

Now its okay, thank you!

Memo1
MC: "Fisch\t"
MC OK!
FP: "Fisch\t"
FP OK!
hydrobyte commented 1 year ago

Nice.