pieroxy / lz-string

LZ-based compression algorithm for JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can you provide a demo for string-to-string decompression?

hsluoyz opened this issue · comments

I saw the nice demo here: https://pieroxy.net/blog/pages/lz-string/demo.html but it doesn't support decompress a string:

image

How did you get that String ? It looks like a Base64 string, the demo page is meant to compress with compressToUTF16 and represent the data in hexadecimal form. Try to input a short string in the top box and hit compress. You will be able to decompress that.

@pieroxy that string is encoded from this function:

export function lzStringEncode(str) {
    return LZString.compressToEncodedURIComponent(str);
}

Is it possible to decode it in the online demo?

Not as of now from the UI. What you can do is press F12 when on the demo page and call LZString directly. For example:

LZString144.compressToEncodedURIComponent("blah blah");
"EYGwhgFgBKlA"
LZString144.decompressFromEncodedURIComponent("EYGwhgFgBKlA");
"blah blah"

@pieroxy yes, it works!

Can you put this function into the UI?

I can sure do that, yes.

@pieroxy thanks! Looking forward to it!