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
首先,您应该找出要使用的压缩算法。我推荐阅读霍夫曼压缩算法。顺便说一句,您使用什么语言?
也许它可以帮助你
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();
}