频道分类

Delphi 对提交参数编码

作者:admin 来源: 日期:2019/10/31 21:56:28 人气: 标签:

 
function ParamsEncode(const ASrc: Ansistring): AnsiString;
var i: Integer;
begin
  Result := '';
  for i := 1 to Length(ASrc) do
  begin
    if (ASrc[i] in ['&', '*','#','%','<','>',' ','[',']'])
       or (not (ASrc[i] in [#33..#128]))
    then
    begin
      Result := Result + '%' + IntToHex(Ord(ASrc[i]), 2);
    end
    else
    begin
      Result := Result + ASrc[i];
    end;
  end;
end;