本文整理自网络,侵删。
function HTTPEncode(const AStr: String): String;const NoConversion = ['A'..'Z','a'..'z','*','@','.','_','-','0'..'9','$','!','''','(',')'];var Sp, Rp: PAnsiChar;begin SetLength(Result, Length(AStr) * 3); Sp:= PAnsiChar(AStr); Rp:= PAnsiChar(Result); while Sp^ <> #0 do begin if Sp^ in NoConversion then Rp^ := Sp^ else if Sp^ = ' ' then Rp^ := '+' else begin FormatBuf(Rp^, 3, '%%%.2x', 6, [Ord(Sp^)]); Inc(Rp,2); end; Inc(Rp); Inc(Sp); end; SetLength(Result, Rp - PAnsiChar(Result));end;function URLEncode(const Url: String): String;begin Result:= HttpEncode(UTF8Encode(Url));end;
相关阅读 >>
Delphi代码,直截注入别的进程,之后直截运行在别的进程中的代码
Delphi的datetostr strtodate格式灵活用法
Delphi 在firemonkey应用程序中使用torientationsensor获取设备倾斜和指南针航向
更多相关阅读请进入《Delphi》频道 >>