lua-users wiki: Read Write Format
Lists of Integers It is often necessary to pack a list of integers into a binary string of data, for example for reading/writing binary files or to implement communication protocols. There are plenty of ways to do this. This implementation has only the pr...