Qu

unpack

Builtin index · Collections & strings

result = unpack(bytes, spec, [endian="little"])

Input: bytes, spec, endian · Output: result

What it is

The inverse of pack: bytes is a byte buffer, spec the same field list.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = unpack(bytes, spec, [endian="little"])
bytes —The inverse of pack: bytes is a byte buffer, spec the same field list.
spec —The inverse of pack: bytes is a byte buffer, spec the same field list.
endian optional (default "little")unpack([0, 1, 255, 254], "i16,i16", endian="big") is [1, -2].
result vector or number
Returns a vector of numbers, one per field. A buffer shorter than the spec needs is an error. unpack([0xAA, 0x10, 0x00, 0x00, 0x00, 0xC0, 0x3F], "u8,u16,f32") is [170, 16, 1.5]; unpack([0, 1, 255, 254], "i16,i16", endian="big") is [1, -2].

Examples

No documentation example calls this form yet. The Collections & strings chapter is where one belongs.