Product SiteDocumentation Site

1.10.4.3. Binary Strings

A binary string is a literal string, expressed using a binary representation of its encoding. It is any sequence of zero or more binary digits (0 or 1) in groups of 8 (bytes) or 4 (nibbles). The first group can have less than four digits; in this case, up to three 0 digits are assumed to the left of the first digit, making a total of four digits. The groups of digits are optionally separated by one or more whitespace characters, and the whole sequence is delimited by matching single or double quotation marks and immediately followed by the symbol b or B. Neither b nor B can be part of a longer symbol. The whitespace characters, which can only be byte or nibble boundaries (and not at the beginning or end of the string), are to improve readability. The language processor ignores them.
A binary string is a literal string formed by packing the binary digits given. If the number of binary digits is not a multiple of 8, leading zeros are added on the left to make a multiple of 8 before packing. Binary strings allow you to specify characters explicitly, bit by bit. These are valid binary strings:

Example 1.8. Valid binary strings

"11110000"b        /* == "f0"x                  */
"101 1101"b        /* == "5d"x                  */
"1"b               /* == "00000001"b and "01"x  */
"10000 10101010"b  /* == "0001 0000 1010 1010"b */
""b                /* == ""                     */

The packed length of a binary-literal string is unlimited.