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 idhttp实现get方法下载文件,断点续传

Delphi tfinddialog treplacedialog对话框在memo中的使用

Delphi提取二值图像轮廓

Delphi xe 获取 android application version 版本

Delphi stringgrid常用属性和常用操作

Delphi 用nethttpclient执行post操作遇到的问题

Delphi自带的indy控件实现md5加密

Delphi 播放声音 建议采用 异步方式,比较流畅

Delphi 将图片压缩后转base64函数

Delphi char数组、string和pchar的相互转换

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



打赏

取消

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

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

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

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

评论

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