Donate Share

JSON delphi library

Tracker: Bugs

5 bug in function strSpecialChars - ID: 2725068
Last Update: Settings changed ( leon_kon )

There is a little bug in the function that filters backslash in a string.
Below the piece of code with fixing.
Thanks, Luca

function strSpecialChars(const s: string): string;
var
i, j : integer;
begin
i := Pos('\', s);
if (i = 0) then
Result := s
else
begin
Result := Copy(s, 1, i-1);
j := i;
repeat
if (s[j] = '\') then
begin
inc(j);
case s[j] of
'\': Result := Result + '\';
'"': Result := Result + '"';
'''': Result := Result + '''';
'/': Result := Result + '/';
'b': Result := Result + #8;
'f': Result := Result + #12;
'n': Result := Result + #10;
'r': Result := Result + #13;
't': Result := Result + #9;
'u':
begin
Result := Result + code2utf(strtoint('$' + copy(s, j + 1,
4)));
inc(j, 4);
end;
end;
end
else
Result := Result + s[j];
inc(j);
// -----> WRONG
// until j >= length(s);
// -----> OK
until j > length(s);
end;
end;


Nobody/Anonymous ( nobody ) - 2009-04-01 13:25

5

Closed

None

Nobody/Anonymous

None

None

Public


Comment ( 1 )

Date: 2009-11-06 00:07
Sender: leon_konProject Admin

fixed, thanks


Attached File

No Files Currently Attached

Changes ( 3 )

Field Old Value Date By
status_id Open 2009-11-06 00:07 leon_kon
allow_comments 1 2009-11-06 00:07 leon_kon
close_date - 2009-11-06 00:07 leon_kon