variable length data types inside a buffer in C : <p>What would be the easiest way to handle serialization of data of variable number of bits put into a uint8 buffer?</p>

<p>For example, the first 4 bits are one variable, then 1 bit is a boolean, another one is 3 bits long. Then you have an array of 8 bytes, and then a 13 bit variable and so on. All this would be written into an unsigned char buffer to be sent over a socket.</p>

<p>The variables data types are sometimes not aligning on 8 bit -16 bit boundaries, they have weird # of bits like 7 bits long, 13 bits long, 3 bits long, etc.</p>

<p>Would it best to write something in C for this, or to use a third party library?</p>
