ZLIB.DLL中BLOB变量压缩与解压函数的使用方法

最近碰上不少朋友问变量压缩的问题,这里整理一下。

函数申明: Function Long compress (Ref blob Destination, Ref ulong DestLen, Ref blob Source, ulong SourceLen ) Library "zlib.dll" Function Long uncompress ( Ref blob Destination, Ref ulong DestLen, Ref blob Sourse, ulong SourceLen ) Library "zlib.dll" 压缩函数: public function long of_compress (ref blob abldestination, blob ablsource)

ulong lulSourceLen long llRC ulong   luldestinationlength

lulSourceLen = Len( ablSource )

luldestinationlength= (lulSourceLen * 101 / 100) + 12

ablDestination = Blob( Space(luldestinationlength),EncodingANSI! )

llRC = compress( ablDestination, luldestinationlength ,ablSource, lulSourceLen )

ablDestination = BlobMid( ablDestination, 1, luldestinationlength)

ablDestination = BLOB("BUFFER=" + STRING(LEN(ablsource)) + ";", EncodingANSI!) + ablDestination

RETURN llRC

解压函数: public function long of_uncompress (ref blob abldestination,  blob ablsource)

ulong lulSourceLen, auldestinationlength long llRC string ls_src long ll_pos

ls_src = STRING(ablSource, EncodingANSI!)

ll_pos = POS(ls_src, ";") IF ll_pos > 0 THEN  ls_src = MID(ls_src, 1, ll_pos)  ablSource = BLOBMID(ablSource, ll_pos + 1)  ll_pos = POS(ls_src, "=")  ls_src = MID(ls_src, ll_pos + 1)  auldestinationlength = LONG(MID(ls_src, 1, LEN(ls_src) - 1)) ELSE  RETURN -1 END IF /

lulSourceLen = Len( ablSource )

ablDestination = Blob( Space(aulDestinationLength), EncodingANSI!)

llRC = uncompress( ablDestination, aulDestinationLength, ablSource, lulSourceLen )

ablDestination = BlobMid( ablDestination, 1, aulDestinationLength )

RETURN llRC 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值