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

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% .)

标签:c,javascript,compression,base64,lzma
来源: https://codeday.me/bug/20190708/1404434.html