Array.pack

Function/Meaning

Returns the array element in octet according to the character string specified by the argument.

Type
Arrayclassmethod of
Syntax
pack(template:string)
Arguments
template

The following characters can be used in the template string.

  • a : ASCII string (null-terminated)
  • A : ASCII string (spaces are completed)
  • b : Binary string (from low-order bit to high-order bit)
  • B : Binary string (from high-order bit to low-order bit)
  • c : Signed 1-byte number (-128 to 127)
  • C : Unsigned 1-byte number (0 to 255)
  • d : Double precision floating point value
  • f : Single precision floating point value
  • h : Hexagonal string (low nybble first)
  • H : Hexic string (high nybble first)
  • i : Signed int number (usually 4 bytes)
  • I : Unsigned int number (usually 4 bytes)
  • l : Signed long number (usually 4 bytes)
  • L : Unsigned long number (usually 4 bytes)
  • n : Unsigned short number (network byte order)
  • N : Unsigned long number (network byte order)
  • s : Signed short number (usually 2 bytes)
  • S : Unsigned short number (usually 2 bytes)
  • v : Unsigned short value (little endian)
  • V : Unsigned long value (little endian)
  • x : Null character
  • X : 1 byte backward
  • @ : Fill null characters to absolute position
  • m : Base64 decode
Return value
None (void)
Explanation

The specified string is called a template.
A template is a list of typed characters and their lengths.
When * is specified as the length, it represents all the remaining lengths.
If the length is omitted, it is treated as 1.