gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:32:37 28 4
gpt4 key购买 nike

我正在使用 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”,它会一直有效,而不仅仅是“压缩”,它并不总是有效。

我亲自测试过它,发现它有效。

(虽然我在C#文件中把Context_Compress_Data.str字段从字符串改成了StringBuilder,因为运行起来太慢了,之后一个8MB的JSON文件只用了8秒,压缩到7%原始尺寸。)

关于c# - 在 .NET 服务器上压缩/解压缩在客户端上使用 lz-string.js 编码的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24512386/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com