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 转换swf到exe

Delphi 官方使用并行编程库介绍

Delphi winapi: setwindowtext - 设置窗口标题

Delphi adoquery 运用

Delphi中提取网址链接分路径

Delphi 切换开关 toggleswitch1

Delphi xe将图标和图像添加为资源

Delphi firedac tfddatamove 导出csv

Delphi 时间年月日,星期

Delphi简单的播放声音

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



打赏

取消

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

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

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

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

评论

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