fmt_pack [function]
fmt_pack( string fmt, ... )
packs the given arguments using the format fmt
and returns the byte buffer or returns null and emits a warning on failure
- the format: character command list
- 0-9: add a digit to multiplier
- =/</>/@: "=" sets host byte order, "<" - little endian byte order, ">" - big endian, "@" - inverted
- +/-: "+" - unsigned integers, "-" - signed integers
- c/w/l/q/p: integers (c - char, 1 byte, w - word, 2 bytes, l - long, 4 bytes, q - quad-word, 8 bytes, p - pointer/size, platform-specific size of 4/8 bytes, usually)
- f/d: floating-point numbers: "f" - single precision, "d" - double precision
- s: string, multiplier sets length instead of count, as with other items
- x: padding byte (does not get read or written, can be used to advance the pointer)
- space/tab/CR/LF: invisible to the parser
- everything else resets multiplier, does nothing
- sign modifiers do nothing in fmt_pack, refer to fmt_unpack() for their usage info
printvar( fmt_pack( "3cf", 0, 1, 2, 3 ) ); // prints 'string [7] "\x00\x01\x02\x00\x00@@"'