Core Function PackSingle
From Sputnik Wiki
PackSingle( <format>, <value> )
Contents |
Description
Pack a single value into a binary array.
Parameters
format
Read Pack( ) to learn about format codes.
Some format codes may not exist in PackSingle() as they do in Pack().
For example you may only a repeater or * if the format code is either : a, A, Z, h, H, z
Any other format code trying to use a reapter or * will result in error.
Currently implemented formats are:
Code Description a NUL-padded string (ASCII) A SPACE-padded string (ASCII) Z NUL-padded string (ASCII) a NUL-terminator will be added to the end regardless *b A bit string (ascending bit order inside each byte, like the Vec() function) *B A bit string (descending bit order inside each byte) h Hex string, low nibble first H Hex string, high nibble first c signed ASCII char C unsigned ASCII char U signed UNICODE char (always 16 bit, machine byte order) W unsigned UNICODE char (always 16 bit, machine byte order) s signed short (always 16 bit, machine byte order) S unsigned short (always 16 bit, machine byte order) n unsigned short (always 16 bit, big endian byte order) v unsigned short (always 16 bit, little endian byte order) i signed integer (machine dependent size and byte order) I unsigned integer (machine dependent size and byte order) l signed long (always 32 bit, machine byte order) L unsigned long (always 32 bit, machine byte order) q signed quad (64-bit) value (always 64 bit, machine byte order) Q unsigned quad (64-bit) value (always 64 bit, machine byte order) N unsigned long (always 32 bit, big endian byte order) V unsigned long (always 32 bit, little endian byte order) f float (machine dependent size and representation) d double (machine dependent size and representation) *p A pointer to a null-terminated string *P A pointer to a fixed-length string t A signed pointer T A unsigned pointer u A uuencoded string z7 string encoded as UTF8 with 1-byte null terminator z6 string encoded as UTF7 with 1-byte null terminator z5 string encoded as UTF16 with 2-byte null terminator z4 string encoded as BigEndianUnicode with 2-byte null terminator z3 string encoded as UTF32 big endian with 4-byte null terminator z2 string encoded as UTF32 with 4-byte null terminator z1 string encoded as ASCII with 1-byte null terminator z0 string encoded as ASCII without a null terminator
Codes with a * are not in PackSingle() yet
value
The value to be used in the packing.
Return Value
Success: Returns the new binary variable.
Failure: Returns null.
Remarks
This is almost the same as Pack( ) but designed to only do one operation thus avoiding the need for excessive parsing and what not the result is more speed.