25.137. pack("format",v1,v2,...,vn)
[<<<] [>>>]
Pack list of arguments into a binary string.
The format strings can contain the packing control literals.
Each of these characters optionally take the next argument and
convert to the specific binary string format. The result is the
concatenated sum of these strings.
Some control characters do not take argument, but result a constant
string by their own.
- SZ the argument is stored as zero terminated string. If the argument
already contains zchar that is taken as termnator and the rest of the
string is ignored.
- S1 the argument is stored as a string. One byte length and maximum 255
byte strings. If the argument longer than 255 bytes only the first 255 bytes
are used, and the rest is ignored.
- S2 same as S1 but with two bytes for the length.
- S3 same as S1 but with three bytes for the length.
- S4 same as S1 but with four bytes for the length.
- S5..8 the same as S1 but with 5..8 bytes for the length.
- Zn one or more zero characters, does not take argument. n can be
1,2,3 ... positive numbers
- In integer number stored on n bytes. Low order byte first. If the number does not
fit into n bytes the higher bytes are chopped. If the number is negative the
high overflow bytes are filled with FF.
- C character (same as I1)
- Un same as In but for unsigned numbers.
- An store the argument as string on n bytes. If the argument is longer than
n bytes only the first n bytes are stored. If the argument is shorter than
n bytes the higher bytes are filled with space.
- R a real number.
See also UNPACK
[<<<] [>>>]