This is the C# do-while loop where, r is a BinaryReader:
int data_len = 0, shift = 0;
byte b;
do
{
b = r.ReadByte();
data_len = data_len | ((b & 0x7F) << shift);
shift += 7;
}
while ((b & 0x80) != 0);
This is what I came up with it fails with large sizes, so it is wrong
data_len = 1 # Because 1 byte is still required to store a zero
shift = 0
b = self.read_uint8()
while (b & 0x80) != 0:
data_len |= (b & 0x7F) << shift
shift += 7
b = self.read_uint8()
return data_len
as well as this:
b = self.read_uint8()
data_len = b & 0x7F
shift = 0
while (b & 0x80) != 0:
b = self.read_uint8()
data_len |= (b & 0x7F) << shift
shift += 7
return data_len
Both do not work.