8000 Doesn't handle unicode characters · Issue #3 · altivi/lz_string · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Doesn't handle unicode characters #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
u3shit opened this issue May 24, 2024 · 1 comment
Open

Doesn't handle unicode characters #3

u3shit opened this issue May 24, 2024 · 1 comment

Comments

@u3shit
Copy link
u3shit commented May 24, 2024

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)

@kiwamizamurai
Copy link

@u3shit

https://rubygems.org/gems/lzstring-ruby/versions/1.0.0

I've created lzstring gem as the complete version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0