加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 在客户端上使用lz-string.js编码的.NET服务器上压缩/解压

发布时间:2020-12-15 22:05:43 所属栏目:百科 来源:网络整理
导读:我使用 lz-string.js的LZString.compressToBase64函数,需要解压缩/压缩服务器端的数据. 显而易见的解决方案似乎是lz_string_csharp,但我很担心 这个说法: If you use just the regular Javascript ‘compress’ function then depending on the data in the
我使用 lz-string.js的LZString.compressToBase64函数,需要解压缩/压缩服务器端的数据.

显而易见的解决方案似乎是lz_string_csharp,但我很担心

这个说法:

If you use just the regular Javascript ‘compress’ function then depending on the data in the string,it will not decompress correctly on the C# side.

However,if you are using the ‘compress’ function built into this C# version,then you should be ok to use the regular ‘decompress’ function included.

关于这个报道的问题:possible bug in c# version of compressToBase64

解决方法

你给出的链接中的完整描述说你应该能够使用’compressToUTF16’并且它总能工作,而不仅仅是’压缩’,这并不总是有效.

我亲自测试过,看到它有效.

(虽然我将Context_Compress_Data.str字段从字符串更改为C#文件中的StringBuilder,因为它运行速度太慢.之后,8 MB JSON文件只需8秒,压缩到原始大小的7% .)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读