I am using LZW as the compression algorithm, that part works fine, but I am trying to convert a binary string of a codeword into bits as to compress the file further.
Here is an example:
Input from file: ababababababbbabac
codeword ( eg ): 12344634
binary for the codeword ( not correct just example )
1 0000001
2 0000010
3 0000011
4 0000101
4 0000101
...
Lets assume that the alphabet consists of the 127 ASCII characters from decimal code 0 to decimal code 126 (tilde), inclusive. Therefore, I will need at least 7 bits per code initially. So how can i convert each element in the binary representation to a bit, and lets say enter into a 7 bit stream? Also how can I read it back, i.e how do i know what each integer bit was entered at and that it doesnt come back as one big long number that cant be broken up into one byte when decompressing?
Thanks any help would be greatly appreciated
John
i have seen this done in C.
Are you trying to get chars into a 7bit numeric representation?