本文整理自网络,侵删。
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 将 4 个 byte 合成 1 个 integer 的五种方法 - 回复 "三足乌" 的问题
Delphi idhashmessagedigest 获取文件md5
Delphi fdconnection1.gettablenames 查看所有表包含用户表和系统表
Delphi使用spcomm没办法触发receivedata
更多相关阅读请进入《Delphi》频道 >>