Character-String to Bit-String Conversion

Character-string to bit-string conversion converts a string of 0 and 1 characters to the 0s and 1s of a bit string. A character-string source value that contains any characters other than 0 and 1, including spaces, cannot be converted to a bit-string value; any attempt to perform such a conversion results in a signal of the ERROR condition.

A character-string value is converted to a bit-string value of the same length as the character string. Each character is converted to a 0 or a 1 bit in the resulting bit string. A null character string is converted to a null bit string.

If the context that caused the conversion gives a target length (for example, assignment to a bit-string variable or use of the BIT built-in function with two arguments), the converted bit string is padded on the right with zero bits to conform to the longer target, or the rightmost excess bits are truncated to conform to a shorter target.

Source     Result
" "B
'010'S '010'B
'  ' invalid, ERROR signaled