@remy/unpack
v2.1.7
Published
Unpacks bytes ala Perl's unpack
Readme
unpack (and pack)
JavaScript module for unpacking and packing based loosely around the Perl packing syntax.
Working demo can be found at unpack.isthe.link.
Lookup table for unpacking:
aA string with arbitrary binary data, will be null padded.Atext (ASCII) string, will be space padded.bA bit string (ascending bit order inside each byte).cA signed char (8-bit) value.CAn unsigned char (octet) value.sA signed short (16-bit) value.SAn unsigned short value.iA signed integer (32-bit) value.IA unsigned integer value.lA signed long (64-bit) value.LAn unsigned long value.nAn unsigned short (16-bit) in "network" (big-endian) order.NAn unsigned long (32-bit) in "network" (big-endian) order.fA single-precision float in native format.dA double-precision float in native format.xA null byte (a.k.a ASCII NUL, "\000", chr(0))
Each type can also include a number, such as A5 will unpack to a 5 byte ascii string.
Unless otherwise stated, endianness can be set to little by using <, such as: <I I L unpacks using little endian 2 32bit unsigned ints and 1 64 bit long.
