ftp://John:[email protected]/20080319/%23%B6%AF%D7%F7%C6%AC%23/%B9%A6%B7%F2/1.rvmb
ftp://John:[email protected]/20080319/#动作片#/功夫/1.rvmb把下面的地址变成上面地址的格式
我到网上找的都是 把所有都变成 URL编码
ftp://John:[email protected]/20080319/#动作片#/功夫/1.rvmb把下面的地址变成上面地址的格式
我到网上找的都是 把所有都变成 URL编码
function FormatURL(Str: string): string;
var
I: Integer;
begin
Result := '';
for I:=1 to Length(Str) do
if (Str[I]='#')or(Ord(Str[I])>127) then
Result := Result + '%' + IntToHex(Ord(Str[I]), 2)
else
Result := Result + Str[I];
end;
Server.URLEncode("内容")
var
Idx: Integer;
begin
Result := '';
for Idx := 1 to Length(S) do
begin
case S[Idx] of
'A'..'Z', 'a'..'z', '0'..'9', '-', '_', '.','@',':','/':
Result := Result + S[Idx];
' ':
if InQueryString then
Result := Result + '+'
else
Result := Result + '%20';
else
Result := Result + '%' + SysUtils.IntToHex(Ord(S[Idx]), 2);
end;
end;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(URLEncode('ftp://John:[email protected]/20080319/#动作片#/功夫/1.rvmb',false));
end;---------------------------
Project1
---------------------------
ftp://John:[email protected]/20080319/%23%B6%AF%D7%F7%C6%AC%23/%B9%A6%B7%F2/1.rvmb
---------------------------
OK
---------------------------