Delphi webservices传base64字串


本文整理自网络,侵删。

 

function CompressStrToBase64(sStr: string): string;
var
  M1: TMemoryStream;
  M0, M2: TStringStream;
begin
  Result := '';
  if sStr = '' then
    Exit;
  M0 := TStringStream.Create(sStr);
  M1 := TMemoryStream.Create;
  M2 := TStringStream.Create(' ');
  try
    M0.Position := 0;
    M1.Position := 0;
    ZCompressStream(M0, M1);
    M1.Position := 0;
    M2.Position := 0;
    EncodeStream(M1, M2);
    Result := M2.DataString;
  finally
    FreeAndNil(M0);
    FreeAndNil(M1);
    FreeAndNil(M2);
  end;
end;

function DeCompressBase64ToStr(sStr: string): string;
var
  M0, M1: TStringStream;
  M2: TMemoryStream;
begin
  Result := '';
  if sStr = '' then
    Exit;
  M0 := TStringStream.Create('');
  M1 := TStringStream.Create(sStr);
  M2 := TMemoryStream.Create;
  try
    M1.Position := 0;
    M2.Position := 0;
    DeCodeStream(M1, M2);
    M0.Position := 0;
    M2.Position := 0;
    ZDecompressStream(M2, M0);
    Result := M0.DataString;
  finally
    FreeAndNil(M0);
    FreeAndNil(M2);
    FreeAndNil(M1);
  end;
end;

相关阅读 >>

Delphi xe7 新的并行库 system.threading

Delphi获取操作系统安装磁盘盘符

Delphi getpublicip 获取公网ip

Delphi opendialog1 添加文件打开多选模式

Delphi 判断字符串是否是单词

Delphi中关闭“返回值…可能未定义”的警告

Delphi中使用自定义字体

Delphi 复制文件到全盘

Delphi 获取其它软件的tlistbox句柄,怎么取得listbox中的数据

Delphi动态创建组件,并释放内存

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



打赏

取消

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

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

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

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

评论

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