Name
binary
- binary
options... Convert data between Tcl string format and machine-dependent binary representation.
- binary format
formatString[args...] Return a binary string in a format defined by
formatStringwith data taken fromargs. The format string consists of zero or more field codes, each followed by an optional integer count. The field codes are listed here:aChars (null padding)
AChars (space padding)
bBinary (low-to-high)
BBinary (high-to-low)
hHex (low-to-high)
HHex (high-to-low)
c8-bit int
s16-bit int (little-endian)
S16-bit int (big-endian)
i32-bit int (little-endian)
I32-bit int (big-endian)
fFloat
dDouble
xNulls
XBackspace
@Absolute position
- binary scan
string formatString[varName...] Parse a binary string according to the format defined in
formatStringand place the results in the specified variable names. Return the number of variables that were set. The format string is the same as for binary format except for the following:aChars (no stripping)
AChars (stripping)
xSkip forward
Example
set i 1234
set j 3.14
set s hello
set str [binary format ida5 $i $j $s]
binary scan $str ida5 i j sBecome an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access