int Read7BitEncodedInt() { int result = 0; int bitsRead = 0; int value; do { value = ReadByte(); result |= (value & 0x7f) << bitsRead; bitsRead += 7; } while (value & 0x80); return result; }
function Read7BitEncodedInt: Integer; var VByte: Byte; Offset: Integer; begin Offset := 0; Result := 0; repeat FInput.Read(VByte, 1); Result := Result or ((VByte and $7F) shl Offset); Inc(Offset, 7); until (VByte and $80) = 0; end;