Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8092653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:19:52+00:00 2026-06-05T20:19:52+00:00

Is there a way to zip a string (either with a gem or standard

  • 0

Is there a way to zip a string (either with a gem or standard lib) so that I can get the zipped result of a string? Example:

"hello world".zip #=> zipped version of string

Also, decompression would be nice if someone could include that in their solution.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T20:19:53+00:00Added an answer on June 5, 2026 at 8:19 pm

    You can use Zlib

    >> require 'zlib'
    => true
    >> s = "this is a long string with many many many many repetition"
    => "this is a long string with many many many many repetition"
    >> s.size
    => 57
    >> cs = Zlib.deflate(s)
    => "x\x9C+\xC9\xC8,V\x00\xA2D\x85\x9C\xFC\xBCt\x85\xE2\x92\xA2L U\x9EY\x92\xA1\x90\x9B\x98W\x89N\x14\xA5\x16\xA4\x96d\x96d\xE6\xE7\x01\x00\\?\x15P"
    >> cs.size
    => 48
    >> is = Zlib.inflate(cs)
    => "this is a long string with many many many many repetition"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there an easy way to recursively ZIP a directory that may or may
Is there way that I can read the file from remote server using fopen
is there a way to get a spring-with-dependencies.zip for the latest version of spring
Is there a way to create a Zip archive that contains multiple files, when
is there way how to get name ov event from Lambda expression like with
Is there a way you can add a column to the Details view of
I wonder whether there is a way to use fastzip to zip a directory,
I'm trying to create a calculator that takes a string that can be in
There was a good link here about how the zip/tarball string is created When
There's a strange problem with DotNetZip that I can't seem to find a solution

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.