On Sat, 13 Mar 2021, Bart via fpc-pascal wrote:

From : 
https://www.freepascal.org/docs-html/current/fcl/fpjson/jsonstringtostring.html

Function result
Pascal string with escaped characters replaced

{$mode objfpc}
{$h+}
uses
 fpjson;

var
   S1, S2: TJSONStringType;
begin
 repeat
   write('S: ');readln(S2);
   S1 := JSONStringToString(S2);
   writeln(S1);
 until S2='';
end.

C:\Users\Bart\LazarusProjecten\ConsoleProjecten>fpc test.pas
Free Pascal Compiler version 3.2.0 [2020/06/04] for i386
Copyright (c) 1993-2020 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling test.pas
Linking test.exe
15 lines compiled, 0.2 sec, 233536 bytes code, 10196 bytes data

C:\Users\Bart\LazarusProjecten\ConsoleProjecten>test
S: \u0041\
A (as expected)
S: \u0042
B (as expected)
S: \"\u0041\
"A (as expected)
S: \"\u0041\"
"A" (as expected)
S: \u0041\u0042
AAB (Huh??)

Do I misunderstand the purpose of this function or is this a bug?

Seems like a bug.

Michael.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to