本文整理自网络,侵删。
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 tfinddialog treplacedialog对话框在memo中的使用
Delphi xe 获取 android application version 版本
Delphi 用nethttpclient执行post操作遇到的问题
Delphi char数组、string和pchar的相互转换
更多相关阅读请进入《Delphi》频道 >>