J
J
I would like to translate the following to C#, and am wondering what is the
simpliest way to replace the "( if (ASrc in UnsafeChars) or (ASrc >=
#$80) or (ASrc[1] < #32)" portion of the code.
function urlEncode(const ASrc: string): string;
const
UnsafeChars = ['*', '#', '%', '<', '>', '+', ' '];
var
i: Integer;
begin
Result := '';
for i := 1 to Length(ASrc) do begin
if (ASrc in UnsafeChars) or (ASrc >= #$80) or (ASrc[1] < #32)
then
Result := Result + '%' + IntToHex(Ord(ASrc), 2)
else
Result := Result + ASrc;
end;
end
simpliest way to replace the "( if (ASrc in UnsafeChars) or (ASrc >=
#$80) or (ASrc[1] < #32)" portion of the code.
function urlEncode(const ASrc: string): string;
const
UnsafeChars = ['*', '#', '%', '<', '>', '+', ' '];
var
i: Integer;
begin
Result := '';
for i := 1 to Length(ASrc) do begin
if (ASrc in UnsafeChars) or (ASrc >= #$80) or (ASrc[1] < #32)
then
Result := Result + '%' + IntToHex(Ord(ASrc), 2)
else
Result := Result + ASrc;
end;
end