微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

我使用 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% .)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐