Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
24
Task/URL-encoding/Delphi/url-encoding.delphi
Normal file
24
Task/URL-encoding/Delphi/url-encoding.delphi
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
function EncodeURL(URL: string): string;
|
||||
var I: integer;
|
||||
begin
|
||||
Result:='';
|
||||
for I:=1 to Length(URL) do
|
||||
if URL[I] in ['0'..'9', 'A'..'Z', 'a'..'z'] then Result:=Result+URL[I]
|
||||
else Result:=Result+'%'+IntToHex(byte(URL[I]),2);
|
||||
end;
|
||||
|
||||
procedure EncodeAndShowURL(Memo: TMemo; URL: string);
|
||||
var ES: string;
|
||||
begin
|
||||
Memo.Lines.Add('Unencoded URL: '+URL);
|
||||
ES:=EncodeURL(URL);
|
||||
Memo.Lines.Add('Encoded URL: '+ES);
|
||||
Memo.Lines.Add('');
|
||||
end;
|
||||
|
||||
procedure ShowEncodedURLs(Memo: TMemo);
|
||||
begin
|
||||
EncodeAndShowURL(Memo,'http://foo bar/');
|
||||
EncodeAndShowURL(Memo,'https://rosettacode.org/wiki/URL_encoding');
|
||||
EncodeAndShowURL(Memo,'https://en.wikipedia.org/wiki/Pikes_Peak_granite');
|
||||
end;
|
||||
Loading…
Add table
Add a link
Reference in a new issue