function FormatStringforCGI(str: string): string;
var
i: integer;
beginfor i := 1 to Length(str) dobeginif str[i] in ['a'..'z', 'A'..'Z', '0', '1'..'9'] then
Result := Result + Str[i]
elseif Str[i] = ' ' then
Result := Result + '+'
else
Result := Result + '%' + IntToHex(Byte(Str[i]), 2);
end;
end;