decode_format 规范

格式字符串由一组字符组成,这些字符指示每个相对位置的自变量类型。

encode 函数的格式字符为:
a fixed width string, right padded with NULLs
Afixed width string, right padded with spaces
Bbignum (encoded as a null terminated string)
ddouble (8 bytes) 
hshort (2 bytes, -32768 through 32767)) 
Hunsigned short (2 bytes, 0 through 65535) 
iinteger (4 bytes, -2147483648 through 2147483647) 
Iunsigned integer (4 bytes, 0 through 4294967295) 
llong long (8 bytes) 
Lunsigned long long (8 bytes) 
Nfixed width number (ascii encoded) 
pposition within the string (only valid for decode) 
vvariable length binary string up to 65535 bytes 
Vvariable length binary string up to 4294967295 bytes 
ybyte (-128 through 127) 
Yunsigned byte (0 through 255) 
Znull terminated string

Modifiers
>	encode number using big endian format

<	encode number using little endian format

对于除 A 和 N 之外的所有格式类型,可以在格式字符后指定一个数字,使该类型重复特定次数。

A 和 N 选项的行为不同于其他选项。 这两者始终仅生成或使用单个固定宽度的输入值。 对于固定长度格式 A 和 N,如果数值大于指定的字段宽度,编码函数会将其截断。

格式i10"表示 10 个整数,而格式A10"表示一个 10 个字符宽的固定宽度字符串。 N5"表示宽度为 5 个字符的固定宽度table.maxndecnumber。

l 和 L(长长整型)格式仅支持 53 位的信息,因为 Lua 的数字格式是双精度值,它使用 53 个位来存储数字,并使用 11 个位来存储阶。

< 和 > 操作符适用于单个格式字符。 格式字符串 "i>ii<"使用大端格式对第一个整数进行编码,使用本地编码(默认)对第二个整数进行编码,使用小端格式对第三个整数进行编码。 格式字符串i10>"表示使用大端格式对 10 个整数进行编码。