C#
's BinaryReader
has a function that according to MSDN, reads an integer encoded as "seven bit integer", and then reads a string with the length of this integer.
Is there a clear documentation for the seven bit integer format (I have a rough understanding that the MSB or the LSB marks whether there are more bytes to read, and the rest bits are the data, but I'll be glad for something more exact).
Even better, is there a C
implementation for reading and writing numbers in this format?
Well, the documentation for BinaryReader.Read7BitEncodedInt already says, that it expects the value to be written with BinaryWriter.Write7BitEncodedInt and that method documentation details the format:
So the integer 1259551277, in binary 1001011000100110011101000101101 will be converted into that 7-bit format as follows:
I'm not that confident in my C skills right now to provide a working implementation, though. But it's not very hard to do, based on that description.