Error in EscapeQuotes function
Posted: 08.04.2006, 00:42
Does anybody else think this function looks wrong
It's from ZDbcPostgreSQLUtils.pas. I assume that the writer meant the middle if statement to read
but I still don't think that would work with strings like \\\'
Anybody have any ideas?
Regards,
Ben.
Code: Select all
function EscapeQuotes(const Value: string): string;
var
I: Integer;
PrevChar, PrevPrevChar: string;
begin
Result := '';
PrevChar := ' ';
PrevPrevChar := ' ';
for I := 1 to Length(Value) do
begin
Result := Result + Value[I];
if (Value[I] = '''') and ((PrevChar <> '\') or
(PrevChar = '\') or (PrevPrevChar = '\')) then
Result := Result + '''';
PrevPrevChar := PrevChar;
PrevChar := Value[I];
end;
end;
Code: Select all
if (Value[I] = '''') and ((PrevChar <> '\') or
((PrevChar = '\') and (PrevPrevChar = '\'))) then
Anybody have any ideas?
Regards,
Ben.