I have a large chunk of binary data in a char [] array, which I need to interpret as an array of packed 6-bit values.
I could sit down and write some code to do this, but I think there must be a good existing class or function that someone has already written.
I need something like:
int get_bits(char* data, unsigned bitOffset, unsigned numBits);
so that I can get the 7th 6-bit character in the data by calling:
const unsigned BITSIZE = 6; char ch = static_cast<char>(get_bits(data, 7 * BITSIZE, BITSIZE));
c ++ bit-manipulation extract
AndrewR
source share