delphi xe HTTPEncode


本文整理自网络,侵删。

 
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 数字排序自动完成

Delphi idhashmessagedigest 获取文件md5

Delphi nethttpclient post 函数

Delphi 关于汉字换行问题

Delphi fdconnection1.gettablenames 查看所有表包含用户表和系统表

Delphi 禁止关机的代码

Delphi fmx 截图

Delphi使用spcomm没办法触发receivedata

Delphi 计算l两个日期的时间间隔月数,月数差

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...