Giter Club home page Giter Club logo

lz-string-python's People

Contributors

eduardtomasek avatar organizetube avatar yuvallanger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

lz-string-python's Issues

Issue with UTF16 decompress

There seems to be some issue in decompressFromUTF16.. the following code does not work. Is there something wrong?

chk_str = "Test String"
compressed = x.compressToUTF16(chk_str)
print(compressed)
print(x.decompressFromUTF16(compressed))

base64 incompatibility with the current lz-string version

Hi,

because of changes made in the encoding method of lz-string(pieroxy/lz-string@2d5a419), the javascript version can produce strings that can't be decompressed with this version.

This example raise an IndexError:

l=lzstring.LZString()
l.decompresFromBase64("A4cwdA9gtAcg9APyA===")

If anyone is interested I've found this https://github.com/pieroxy/lz-string/blob/0dda98caa06c4c09e251a96378538169dfbc5a5f/libs/lz-string.js as the last version compatible.

Padding issue!

import lzstring


x = "N4IgLgngDgpiBcIBGAnAhgOwCYgDQgBs0EQYM8QBHASxIAYBaGAOSwAUAOAMzAHY0AYgHcAWtQCuADQD2WNAQBeADyRIhCgIIBFLABlpANQIARAEIBNABIQAVlwCi0gKoBZALwVK4mN4QBGfAB9Ej8/Og46EABfIAAA="

z = lzstring.LZString().decompressFromBase64(x)

y = lzstring.LZString().compressToBase64(z)

print(y)

print(x == y)

The padding is incorrect!

What's the license?

Hi,

I'd like to use this in a little project I'm working on at work, and I was wondering if you could clarify the license this code is under. Is it WTFPL like lz-string itself?

Many thanks!

Extreme compression!

Taking this code out for a spin, because I use Python to generate JS code in one application, I loaded a random text file off my system into Python, it was 253990 characters, and ran compress, and got 41993 characters back. It decompressed fine. Yay!

But then I tried out compressToUTF16, and got 8 characters back. And there seems not to be a decompressFromUTF16! But I sort of doubt that 8 characters could hold the original file...

Does this work with the current version?

import lzstring

x = lzstring.LZString()

print x.compressToBase64("Dak0tajdjdjdddddddddddddddddddddddd")

Error:
Traceback (most recent call last):
File "try.py", line 5, in
print x.compressToBase64("Dak0tajdjdjdddddddddddddddddddddddd")
File "/home/solstice/lzstring.py", line 256, in compressToBase64
string = self.compress(string)
File "/home/solstice/lzstring.py", line 64, in compress
context_data_string += chr(context_data_val)
ValueError: chr() arg not in range(256)

the context_data_val is 2180 at this point!!

Weird error decompressing in base64

Hi,
When I execute in python

a = "N4IgKgTglghgNgBQPZQHYBcQC4DaOCMALPgOwn4AcJFhAnAMwkA0IAVOwAQDK6ME6HdNHgd2rEAF0JAXyAA="
x = lzstring.LZString()
x.decompresFromBase64(a)

it throws me the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "lzstring.py", line 578, in decompresFromBase64
    output += chr(output_ | chr2)
ValueError: chr() arg not in range(256)

But in the javascript implementation it decodes it perfectly.

Surrogates Error Decompressing UTF-16

Im trying to decompress an api response that is compressed in utf-16 but when i try it i get the following error "UnicodeEncodeError: 'utf-8' codec can't encode character '\udc00' in position 0: surrogates not allowed" (note that the character is not always the same). I researched it and i found that the character is probably an emoji. I tryied to encode and decode the string before the decpmpress with surrogateescape, or surrogatepass with no luck.. Any idea how to fix it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.