Coder Social home page Coder Social logo

lz_string's People

Contributors

altivi avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

lz_string's Issues

Doesn't handle unicode characters

The javascript version (1.5.0 from npm) handles unicode characters in the input string:

> lz=require('lz-string')
> lz.compressToBase64('ö')
'G9A='
> lz.decompressFromBase64(lz.compressToBase64('ö'))
'ö'
> lz.decompressFromBase64(lz.compressToBase64('\u2764'))
'❤'
> lz.decompressFromBase64(lz.compressToBase64('\u{1f3b6}'))
'🎶'

Doing the same in the ruby version (0.2.0) fails:

[10] pry(main)> LZString::Base64.decompress LZString::Base64.compress "ö"
=> "\xF6"
[11] pry(main)> LZString::Base64.decompress LZString::Base64.compress "\u2764"
=> nil
LZString::Base64.decompress LZString::Base64.compress "\u{1f3b6}"
=> nil

In addition, for the last emoji, compress returns different values (jwbjb9o= from javascript, m3PQ from ruby). Seems like the ruby version expects latin1 on input, fails miserably on characters outside of it, and returns a string with wrong encoding (Binary instead of ISO8859_1)

Looks like you're requiring pry, but don't have it listed as a dependency.

https://github.com/Altivi/lz_string/blob/220f64f53953e02e2fbb75c4e03ee82813c11dcc/lib/lz_string.rb#L1

	3: from decode.rb:1:in `<main>'
	2: from decode.rb:1:in `require'
	1: from /Users/something/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/lz_string-0.1.1/lib/lz_string.rb:1:in `<top (required)>'
/Users/something/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/lz_string-0.1.1/lib/lz_string.rb:1:in `require': cannot load such file -- pry (LoadError)```

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.