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 6588867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:06:05+00:00 2026-05-25T17:06:05+00:00

I have a bitset of binary data that I wish to encode compactly as

  • 0

I have a bitset of binary data that I wish to encode compactly as an ASCII string. I intend to initially compress the data using run-length encoding to give a sequence of integers; e.g.

111110001000000000000111

becomes:

5o3z1o12z3o

(e.g. 5 ones, 3 zeros, 1 one, 12 zeros, 3 ones).

However, I wish to then compress this further into a compact ASCII string (i.e. a string using the full range of ASCII characters rather than the digits plus ‘o’ and ‘z’). Can anyone recommend a suitable approach and / or 3rd party library to do this in Java?

  • 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-05-25T17:06:06+00:00Added an answer on May 25, 2026 at 5:06 pm

    If your goal is compression, just gzip the stream. It’s going to do better than your run-length encoding.

    Then if you need it to be text for some reason, like to safely pass through old mail gateways, I’d also turn to a standard encoding like Base64, rather than make up your own.

    But if you want to roll your own: first I’d note that you don’t need the ‘o’ and ‘z’. You already know those values since they alternate. Assume it starts on 0 (and if it doesn’t, encode an initial 0 to show that there are 0 0s).

    Encoding the numbers textually is possible but probably inefficient. Look into a variable-length encoding for integer values, then encode those bytes. Then ‘escape’ them into ASCII somehow.

    But then we’re back to Base64-like encoding, and the first suggestion to gzip + Base64 is probably easier than all of this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have tried to implement following code #include <iostream> #include <bitset> using namespace std;
I have a long running insert transaction that inserts data into several related tables.
I have a std::bitset that I'd like to write to a file, bit for
I have bitset<8> v8 and its value is something like 11001101, something in binary,
I have byte to binary string function, std::string byte_to_binary(unsigned char byte) { int x
I have been using the Bitset class in Java and I would like to
I have some Java code which performs bitwise operations on a BitSet. I have
Have just started using Google Chrome , and noticed in parts of our site,
Have just started using Visual Studio Professional's built-in unit testing features, which as I
I have an input stream from a binary file. I want to create a

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.