码迷,mamicode.com
首页 > Windows程序 > 详细

delphi EncdDecd.pas单元中Encoding方法出现#$D#$A的解决方法

时间:2015-06-26 16:20:01      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:

例如:

s:= ‘http://detail.tmall.com/item.htm?id=45545826531&abbucket=_AB-M129_B17&acm=03130.1003.1.161728&aldid=4HatiDee&abtest=_AB-LR129-PV129_1393&scm=1003.1.03130.13_45545826531_161728&pos=6#detail‘;

s:=Encoding(s);  //加密后的字符串中间就会多了#$D#$A,例如‘ABCDDDD‘#$D#$A‘DDESDFGF‘


该单元为你的Delphi安装目录下,解决方法是将该单元放到你的程序源代码文件夹下,并Shift+F11在项目中添加该单元,这样就会引用你程序单元的EncdDecd.pas,而不会去引用delphi安装目录下的EncdDecd.pas单元。

 并且要增加一行代码,替换掉那个字符串:

function EncodeString(const Input: string): string;
var
  InStr, OutStr: TStringStream;
  str_result   : string;
begin
  InStr := TStringStream.Create(Input);
  try
    OutStr := TStringStream.Create(‘‘);
    try
      EncodeStream(InStr, OutStr);
      str_result := OutStr.DataString;    
      str_result := StringReplace(str_result,#$D#$A,‘‘,[rfReplaceAll,rfIgnoreCase]);  //增加代码!!!
      Result     := str_result;
    finally
      OutStr.Free;
    end;
  finally
    InStr.Free;
  end;
end;

delphi EncdDecd.pas单元中Encoding方法出现#$D#$A的解决方法

标签:

原文地址:http://blog.csdn.net/xtfnpgy/article/details/46650501

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!