github.com/hirochachacha/plua@v0.0.0-20170217012138-c82f520cc725/stdlib/string/testdata/unpack.lua (about)

     1  i, pos = string.unpack(">i9", "\0\0\0\0\0\0\0\0\1")
     2  assert(pos == 10  and i == 1)
     3  i, pos = string.unpack("<i9", "\1\0\0\0\0\0\0\0\0")
     4  assert(pos == 10  and i == 1)
     5  i, pos = string.unpack(">i10", "\255\255\255\255\255\255\255\255\255\253")
     6  assert(pos == 11  and i == -3)
     7  i, pos = string.unpack("b", "\128")
     8  assert(pos == 2 and i == -128)
     9  i, pos = string.unpack("b", "\130")
    10  assert(pos == 2 and i == -126)
    11  s, pos = string.unpack("s", "\3\0\0\0\0\0\0\0abc")
    12  assert(pos == 12 and s == "abc")
    13  s, pos = string.unpack("z", "abc\0")
    14  assert(pos == 5 and s == "abc")