I am documenting an old file format and have stumped myself with the following issue.
It seems to be that integers are variable-length encoded, with numbers <= 0x7F
encoded in a single byte, but >= 0x80
are encoded in two bytes. An example set of integers and their encoded counterparts:
0x390
is encoded as0x9007
0x150
is encoded as0xD002
0x82
is encoded as0x8201
0x89
is encoded as0x8901
I have yet to come across any numbers that are larger than 0xFFFF
, so I can't be sure if/how they are encoded. For the life of me, I can't work out the pattern here. Any ideas?