{"id":27498311,"url":"https://github.com/kiwamizamurai/lzstring_ruby","last_synced_at":"2026-02-22T21:11:04.248Z","repository":{"id":287289896,"uuid":"964245783","full_name":"kiwamizamurai/lzstring_ruby","owner":"kiwamizamurai","description":"A Ruby port of lz-string - a string compression algorithm with support for multiple encodings (base64, URI, UTF16) and seamless JavaScript interoperability ","archived":false,"fork":false,"pushed_at":"2025-08-10T00:16:37.000Z","size":41,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-14T16:08:24.785Z","etag":null,"topics":["lz-string","lzstring","ruby","string-compression"],"latest_commit_sha":null,"homepage":"https://kiwamizamurai.github.io/lzstring_ruby/","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kiwamizamurai.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"kiwamizamurai","open_collective":"kiwamizamurai","patreon":"kiwamizamurai"}},"created_at":"2025-04-10T23:08:19.000Z","updated_at":"2025-08-10T00:16:40.000Z","dependencies_parsed_at":"2025-04-14T11:01:07.703Z","dependency_job_id":null,"html_url":"https://github.com/kiwamizamurai/lzstring_ruby","commit_stats":null,"previous_names":["kiwamizamurai/lzstring_ruby"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/kiwamizamurai/lzstring_ruby","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiwamizamurai%2Flzstring_ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiwamizamurai%2Flzstring_ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiwamizamurai%2Flzstring_ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiwamizamurai%2Flzstring_ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kiwamizamurai","download_url":"https://codeload.github.com/kiwamizamurai/lzstring_ruby/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiwamizamurai%2Flzstring_ruby/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29727153,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-22T20:09:16.275Z","status":"ssl_error","status_checked_at":"2026-02-22T20:09:13.750Z","response_time":110,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lz-string","lzstring","ruby","string-compression"],"created_at":"2025-04-17T08:31:34.389Z","updated_at":"2026-02-22T21:11:04.243Z","avatar_url":"https://github.com/kiwamizamurai.png","language":"Ruby","readme":"# LZString Ruby\n\n![Gem Version](https://img.shields.io/gem/v/lzstring-ruby)\n![Gem Total Downloads](https://img.shields.io/gem/dt/lzstring-ruby)\n![Gem download rank](https://img.shields.io/gem/rd/lzstring-ruby)\n[![Ruby](https://github.com/kiwamizamurai/lzstring_ruby/actions/workflows/main.yml/badge.svg)](https://github.com/kiwamizamurai/lzstring_ruby/actions/workflows/main.yml)\n[![Coverage Status](https://img.shields.io/badge/coverage-100%25-brightgreen.svg)](https://github.com/kiwamizamurai/lzstring-ruby)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nA Ruby port of lz-string - a string compression algorithm with support for multiple encodings (base64, URI, UTF16) and seamless JavaScript interoperability\n\nhttps://www.ruby-toolbox.com/projects/lzstring-ruby\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'lzstring-ruby'\n```\n\nAnd then execute:\n\n```bash\n$ bundle install\n```\n\nOr install it directly:\n\n```bash\n$ gem install lzstring-ruby\n```\n\n## Usage\n\n### Basic Compression/Decompression\n\n```ruby\nrequire 'lzstring'\n\n# Standard compression\ncompressed = LZString.compress(\"Hello, world!\")\ndecompressed = LZString.decompress(compressed)\nputs decompressed # =\u003e \"Hello, world!\"\n\n# Base64 compression\nbase64 = LZString.compress_to_base64(\"Hello, world!\")\noriginal = LZString.decompress_from_base64(base64)\nputs original # =\u003e \"Hello, world!\"\n\n# URI-safe compression\nuri_safe = LZString.compress_to_encoded_uri_component(\"Hello, world!\")\noriginal = LZString.decompress_from_encoded_uri_component(uri_safe)\nputs original # =\u003e \"Hello, world!\"\n\n# UTF16 compression\nutf16 = LZString.compress_to_utf16(\"Hello, world!\")\noriginal = LZString.decompress_from_utf16(utf16)\nputs original # =\u003e \"Hello, world!\"\n\n# Uint8Array compression\nuint8 = LZString.compress_to_uint8_array(\"Hello, world!\")\noriginal = LZString.decompress_from_uint8_array(uint8)\nputs original # =\u003e \"Hello, world!\"\n```\n\n### Custom Encoder\n\n```ruby\nrequire 'lzstring'\n\ndictionary = \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+-=\"\ncustom_compressed = LZString.compress_to_custom(\"Hello, world!\", dictionary)\noriginal = LZString.decompress_from_custom(custom_compressed, dictionary)\nputs original # =\u003e \"Hello, world!\"\n```\n\n## Command Line Interface\n\nThe gem includes a command-line tool for compressing and decompressing files:\n\n```bash\n# Compress a file\n$ lzstring input.txt \u003e output.txt\n\n# Decompress a file\n$ lzstring -d input.txt \u003e output.txt\n\n# Compress with base64 encoding\n$ lzstring -e base64 input.txt \u003e output.txt\n\n# Decompress from base64 encoding\n$ lzstring -d -e base64 input.txt \u003e output.txt\n\n# Save to output file\n$ lzstring -o output.txt input.txt\n\n# Get help\n$ lzstring -h\n```\n\n### CLI Options\n\n```\nUsage: lzstring [options] [input-file]\n\nUse lz-string to compress or decompress a file\n\nArguments:\n  input-file                  file to process, if no file then read from stdin\n\nOptions:\n  -V, --version               output the version number\n  -d, --decompress            if unset then this will compress\n  -e, --encoder \u003ctype\u003e        character encoding to use (choices: \"base64\", \"encodeduri\", \"raw\", \"uint8array\", \"utf16\", default: \"raw\")\n  -o, --output \u003coutput-file\u003e  output file, otherwise write to stdout\n  -q, --quiet                 don't print any error messages\n  -h, --help                  display help for command\n```\n\n## Implementation Notes\n\nThis Ruby implementation closely follows the original JavaScript lz-string library, with a few important notes:\n\n### Character Encoding\n\nRuby handles character encoding differently from JavaScript. This implementation uses UTF-8 encoding for all string operations to ensure compatibility with the JavaScript version. The library includes special handling for multibyte characters, ensuring proper UTF-8 encoding throughout the compression and decompression process.\n\n### Unicode Support\n\nThe implementation supports basic Unicode characters and includes robust error handling for edge cases. Due to differences in how Ruby and JavaScript handle character encodings, some complex Unicode characters might not compress/decompress perfectly.\n\n## Compatibility\n\nThis gem is designed to be compatible with the original JavaScript [lz-string](https://github.com/pieroxy/lz-string) library. It can decompress data compressed by the JavaScript library and vice versa.\n\nExample of cross-platform usage:\n\n```javascript\n// JavaScript\nconst compressed = LZString.compressToBase64('Hello, world!');\n// Pass this compressed string to your Ruby application\n```\n\n```ruby\n# Ruby\noriginal = LZString.decompress_from_base64(compressed_from_js)\nputs original # =\u003e \"Hello, world!\"\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake quality` to run the tests, RuboCop checks, and YARD documentation generation.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Code Quality\n\nThe codebase is fully covered by:\n- Comprehensive test suite with 100% coverage\n- RuboCop for style checking\n- YARD for documentation\n\nRun all quality checks:\n\n```bash\n$ bundle exec rake quality\n```\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","funding_links":["https://github.com/sponsors/kiwamizamurai","https://opencollective.com/kiwamizamurai","https://patreon.com/kiwamizamurai"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkiwamizamurai%2Flzstring_ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkiwamizamurai%2Flzstring_ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkiwamizamurai%2Flzstring_ruby/lists"}