Compress / decompress a string on a .NET server that has been encoded using lz-string.js on a client

I use the function LZString.compressToBase64 lz-string.js and you need to unzip / compress the data on the server side.

The obvious solution seems lz_string_csharp , but it bothers me

this statement:

If you use only the Javascript "compression" function, then depending on the data in the line, it will not be correctly unpacked by C #.

However, if you use the "compress" function built into this version of C #, you must be fine to enable the normal "unzip" function.

and about this reported problem: possible error in C # version for ToBase64 compression

+4
source share
2 answers

The full description of the link you are giving suggests that you should use "compressToUTF16" and it will always work, not just "compress", which will not always work.

I checked it personally and saw that it works.

(Although I changed the Context_Compress_Data.str field from a string to StringBuilder in a C # file because it was too slow to run. After that, it only took 8 seconds for the 8 MB JSON file to be compressed to 7% original size.)

+1
source

, enc1 = enc2 = enc3 = enc4 = 0; ( 580 )

, , enc1, enc2 ..... reset , .

  i += 3;

                    enc1 = enc2 = enc3 = enc4 = 0;

                    enc1 = (int)(Math.Round(chr1)) >> 2;
0

Source: https://habr.com/ru/post/1546697/


All Articles