Question: I need to transmit integral data types over the network but don't want to transfer all 32 (or 64) bits all the time - data fits into just one byte 99% of time - so it looks like it's need to compress it somehow: for example first bit of a byte is 0 if other 7 bits means just some value (0-127), otherwise (if first byte is 1) it's need to shift these 7 bytes left and read second byte to do the same process.

Is there some common way to do this? I don't want to reinvent a wheel...

Thank you.

Answer: 
The scheme you describe (which is essentially a base-128 encoding: each byte is a 7-bit base-128 "digit" and a single bit flag to indicate whether or not it is the final digit) *is* a common way of doing this.

For example, see:

* the section on "LEB128" in the [DWARF spec](http://www.dwarfstd.org/doc/DWARF4.pdf) (§7.6);
* "Base 128 Varints" in [Google's protocol buffers](http://code.google.com/apis/protocolbuffers/docs/encoding.html);
* "Variable Width Integers" in the [LLVM bitcode format](http://llvm.org/docs/BitCodeFormat.html) (various different widths are used in various different places there).
Just about *any* data compression algorithm would be able to compress that kind of data stream very well. Use whatever compression libraries your language provides.