Need to encode & decode byte-stream (containing non-ascii characters possibly), from/into uint16, uint32, uint64 (their typical C/C++ meaning), taking care of endianness. What is an efficient & hopefully cross-platform way to do such a thing in Lua ?
My target arch is 64-bit x86_64, but would like to keep it portable (if it doesn't cost me on performance front).
e.g.
decode (say currently in a Lua string) -- 0x00, 0x1d, 0xff, 0x23, 0x44, 0x32 (little endian) as - uint16: (0x1d00) = 7424 uint32: (0x324423ff) = 843326463
Would be great if someone can explain with an example.