编码上面的函数可以工作,但它们的编码方式不同。
Tchromium 需要一个非常具体的、足够具体的以不创建典型功能。
HttpEncode 几乎可以完美运行,但会编码特殊字符,例如 +、- 等。
我尝试作者的功能:
stackoverflow.com/questions/776302/standard-url-encode-function
我试试
function MyEncodeUrl(source: string): string;
var i:integer;
begin
result := '';
for i := 1 to length(source) do
if not (source[i] in ['A'..'Z','a'..'z','0','1'..'9','-','_','~','.']) then result := result + '%'+inttohex(ord(source[i]),2) else result := result + source[i];
end;
但是,我在'/'之间的片段上使用了上述函数,例如:
path := ExtractFilePath(Application.ExeName) ;
function GenerateURL(path: string): string;
var after,temp: string;
begin
path:= ExtractFilePath(Application.ExeName);
after:=Copy(path,1,4);
Delete(path,1,3);
while (Pos('\',path)>0 )do
begin
wynik:=Copy(path,1,Pos('\',path)-1);
if Length(temp)<>0 then
temp:=MyEncodeUrl(temp)+'\';
Insert(temp,after,Length(s));
Delete(path,1,Pos('\',path))
end ;
Delete(after,(Length(after)),1);
Result := StringReplace(after, '\', '/', [rfReplaceAll]);
end;
在上述函数之后,我只是添加 URL 函数的开头和结尾:
URL := 'file:///' + GenerateUrl(path)+ 'page.htm';
感谢大家的帮助