The comment in the rotor code is quite clear: // Write out an int 7 bits at a time. The high bit of the byte, // when on, tells reader to continue reading more bytes. A length prefix consists of zero or more bytes in the 128-255 range and one byte in the 0-127 range. The binary number zzyy.yyyy.yxxx.xxxx is encoded as 1xxxxxxx 1yyyyyyy 000000zz The rotor code for reading: 474: protected int Read7BitEncodedInt() { 475: // Read out an int 7 bits at a time. The high bit 476: // of the byte when on means to continue reading more bytes. 477: int count = 0; 478: int shift = 0; 479: byte b; 480: do { 481: b = ReadByte(); 482: count |= (b & 0x7F) << shift; 483: shift += 7; 484: } while ((b & 0x80) != 0); 485: return count; 486: }