NET/MASTER Network Control Language (NCL) Reference Manual

B2C
Built-in Functions
4–8 106126 Tandem Computers Incorporated
B2C The B2C built-in function converts a string of binary digits to characters.
B2C(
string
)
string
specifies the source data to be converted. It must consist of 0s (zeros), 1s, or
spaces. Spaces are permitted only at byte boundaries, not at the start or end of the
string. A binary string can consist of any number of 0s or 1s; these are converted
into characters to form one or more bytes. A null string returns a null string.
Considerations
If the number of nonspace characters is not a multiple of 8 (one byte), the returned
string is padded on the left with 0s.
The output string is formed by packing each group of eight 0s or 1s into a single
byte.
Left-to-right bit assignment is assumed, both for bits in bytes and bytes in storage.
See also C2B, which converts a string to its binary equivalent.
Examples
The following example converts the binary string contained in parentheses to the
ASCII string “A MESSAGE”:
&RESULT = B2C(01000001 00100000 01001101 01000101 01010011,
01010011 01000001 01000111 01000101)
The following example converts the binary string “10000001” to the hexadecimal value
'81'x. As in the examples for the built-in function A2E, the string is converted to a
displayable hexadecimal string by using the built-in function C2X:
&A = "10000001"
&RESULT = C2X(B2C(&A))
The following two examples result in an error because these strings contain illegally
placed spaces:
SAY "A SPACE AT THE BEGINNING OF A STRING CAUSES AN ERROR"
SAY B2C(‘ 10000001’)
SAY "SO DOES A SPACE NOT ON A BYTE BOUNDARY"
SAY B2C(10000 001)