如何将如url编码。就是如同IE浏览器地址栏的URL地址编码。 (100分)

  • 主题发起人 主题发起人 Benesoft
  • 开始时间 开始时间
B

Benesoft

Unregistered / Unconfirmed
GUEST, unregistred user!
如将:http://127.0.0.1:7001/spotxml?condition=一号仓库
转换成:http://127.0.0.1:7001/spotxml?condition=%2D%4E%5B%6C%2C%1B%2A%7E
这种形式?
要求不用控件,最好有源程序。谢谢各位。。。
 
用intraweb开发,
URL形式就是这样的。
 
TNMHTTP中有函数可以完成,好像是Encode***,具体名字忘了
 
可以的,用wininet里的url方面的函数
 
只有张无。。的具有意义,但不能解决。还有没有别的!在线关注中。。。
 
function encodeURL(const enUrl:string):string;
var
HexBuffer:array[0..1] of char;
SourcePtr:Pchar;
binChar,tmpchar:Char;
i,i1,isize:integer;
enStr:string;
isHostpart,isParaName:boolean;
begin
isHostpart:=true;
isParaName:=true;
binChar:=#0;
enStr:='';
isize:=length(enUrl);
SourcePtr:=PChar(enUrl);
for i:=0 to isize do
begin
binChar:=SourcePtr;

//Host Address and Document Part
if ((binChar <> '?') and (isHostpart)) then
begin
enStr:=enStr+binChar;
end else //Query parameters Part
begin
if (binChar <> '?') then
begin
if ((binChar = '&') or (isParaName)) then //parameter name part
begin
if (not ((binChar = '=') or (binChar = '&'))) then
enStr:=enStr+binChar;
if (binChar = '=') then
begin
enStr:=enStr+binChar;
isParaName:=false;
end;
if (binChar = '&') then
begin
if ((i+1) = isize) then
enStr:=enStr+'%26';
for i1:=i+1 to isize do
begin
tmpchar:=SourcePtr[i1];
if (tmpchar = '&') then
begin
isParaName:=false;
enStr:=enStr+'%26';
break;
end;
if (tmpchar = '=') then
begin
isParaName:=true;
enStr:=enStr+'&';
break
end;
end;
end;
end else //parameter value part
begin
if (binChar>#127) then//GBK Part
begin
BintoHex(@binChar,HexBuffer,1);
enStr:=enStr+'%'+HexBuffer;
end else //ASCII Part
begin
case binChar of
' ': enStr:=enStr+'+';
'''': enStr:=enStr+'%27';
'"': enStr:=enStr+'%22';
'&': enStr:=enStr+'%26';
'=': enStr:=enStr+'%3D';
'`': enStr:=enStr+'%60';
'~': enStr:=enStr+'%7E';
'!': enStr:=enStr+'%21';
'#': enStr:=enStr+'%23';
'$': enStr:=enStr+'%24';
'%': enStr:=enStr+'%25';
'^': enStr:=enStr+'%5E';
'(': enStr:=enStr+'%28';
')': enStr:=enStr+'%29';
'+': enStr:=enStr+'%2B';
':': enStr:=enStr+'%3A';
';': enStr:=enStr+'%3B';
'<': enStr:=enStr+'%3C';
'>': enStr:=enStr+'%3E';
',': enStr:=enStr+'%2C';
'?': enStr:=enStr+'%3F';
'/': enStr:=enStr+'%2F';
'|': enStr:=enStr+'%7C';
'/': enStr:=enStr+'%5C';
else
enStr:=enStr+binChar;
end;
end;
end;
end else
begin
enStr:=enStr+binChar;
isHostpart:=False;
end;
end;
end;
Result:=enStr;
end;
 
后退
顶部