Datastorage: What is the best way to save an Index?

As the title suggests, I am asking for what is the best way to save ‘inventory data’. Here are the ideas that I got to minimize bytedata usage whilst being accurate on the reader-end.

1. Int32 Index

The first thing that I thought off was Int32 Index. As Int32 / Bit32 can store an integer between 0 and (2^32)-1, it is a good way to store integers. But here is the problem: Each of my Item would have an Index, between 1 and how many items there are. I’d doubt that I would even make over 1000 items, and so only about 16 bits / 2 bytes of Data would actually be used in the Int32.

2. Character Bytedata

To preserve space, this may be a good solution as it can support a smaller range of integers as a character can represent an integer between 0 and 255 (2^8-1), so having two characters next to each other could support (2^16)-1 / 65535 integers.

The problem is that not all characters’ bytedata is read as it was written. An example is inverseing a string, it should put out the characters with their bytedata not’d, and inversing it again should reveal the original number, but it doesn’t. I got an example of the function in my Bit32 & Binary tutorial.

3. Latin script

If we use all the letters in the Latin script (what English uses), we would have 52 characters to choose from (26 upper and 26 lower). If we add other supported characters, for example aumlauted characters like: Üü, Öö, Ää, we would have an extra 6 characters.

If we use both the aumlauted and English characters, we would have 58 possible characters.

If we just have a sequence of two of these characters to represent an index, we would have 58^2 of possible indexes, So we can store 3364 indexes each to represent a single number in 16 bits / 2 bytes, which is already more effiecent than storing 32 bits in number form and not using most of the bits.

4. Russian Carilic

This is the same idea as the Latin script, but with more characters.

The Russian carilic script has 33 letters, (66 characters in total), and it would have an even larger range of indexes.

Russian carilic is also quite well supported, so it should not cause any dataloss. But there would be a larger range of indexes, most of which we don’t need.

The English - Latin script alone would already have more than enough indexes.

Edit: 5. Bytepacked Data

We could store 4 indexes into an Int32 number with bytepacking, but the Indexes would be limited to 255.
If we store just 3 indexes into an Int32 number, we would only use 30 of the bits with 10 bits each, or 2^10-1. If we store just 2 indexes into a bit32, it would be no different to storing the character data but just in number form.

If we go with storing 3 indexes in an Int32, each would have 10 bits and the Index would max out to 1023, which would leave little wasted.

(But we do waste 2 bits, but that we would save 3 indexes into 32 bits instead of 2 indexes with the character bytedata method, and we would use 3x less data then storing the Int32 seperately, as 3 indexes would be 96 bits long, which would be a waste when we could just store it in 32 bits.)