سؤال

I am trying to pack characters into bits in terms of 0's and 1's. I have looked up many websites about bit-packing but I did not get any of them.

I just want a simple idea about bit-packing, and how to do it?

Thanks

هل كانت مفيدة؟

المحلول

A common compression algorithim which has been around a long time is LZW compression.

It is used by GZIP, PKZIP and JAR to name but a few and is suitable for compressing text. It uses a combination of Huffman encoding, arithmetic coding and a few heuristics to make it more efficient.

simple idea about bit-packing

If you find compression and bit packing in general simple, you are a rare breed. ;)

نصائح أخرى

Perhaps it can help you

public String StringtoBinary(String s) {

    char[] cArray=s.toCharArray();

    StringBuilder sb=new StringBuilder();

    for(char c:cArray)
    {
        String cBinaryString=Integer.toBinaryString((int)c);
        sb.append(cBinaryString);
    }

    return sb.toString();
}

First of all you should find out what compression algorithm you want to use. I recommend reading Huffman compression algorithm. What language are you using BTW ?

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top