Core Function PackSingle
From Sputnik Wiki
(Difference between revisions)
(→format) |
(→format) |
||
Line 16: | Line 16: | ||
For example you may only a repeater or * if the format code is either : | For example you may only a repeater or * if the format code is either : | ||
− | a, A, Z, h, H, z | + | a, A, Z, h, H, z, b, B |
Any other format code trying to use a reapter or * will result in error. | Any other format code trying to use a reapter or * will result in error. | ||
Line 27: | Line 27: | ||
A SPACE-padded string (ASCII) | A SPACE-padded string (ASCII) | ||
Z NUL-padded string (ASCII) a NUL-terminator will be added to the end regardless | 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, low nibble first | ||
H Hex string, high nibble first | H Hex string, high nibble first | ||
Line 49: | Line 49: | ||
f float (machine dependent size and representation) | f float (machine dependent size and representation) | ||
d double (machine dependent size and representation) | d double (machine dependent size and representation) | ||
− | |||
− | |||
t A signed pointer | t A signed pointer | ||
T A unsigned pointer | T A unsigned pointer | ||
Line 63: | Line 61: | ||
z0 string encoded as ASCII without a null terminator | z0 string encoded as ASCII without a null terminator | ||
</pre> | </pre> | ||
− | |||
− | |||
==== value==== | ==== value==== |
Revision as of 11:32, 13 June 2015
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, b, B
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) 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
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.