Product SiteDocumentation Site

7.4.79. X2B (Hexadecimal to Binary)


>>-X2B(hexstring)----------------------------------------------><

Returns a string, in character format, that represents hexstring converted to binary. The hexstring is a string of hexadecimal characters. It can be of any length. Each hexadecimal character is converted to a string of 4 binary digits. You can optionally include whitespace characters in hexstring (at byte boundaries only, not leading or trailing) to improve readability; they are ignored.
The returned string has a length that is a multiple of 4, and does not include any whitespace.
If hexstring is null, the function returns a null string.
Here are some examples:

Example 7.107. Builtin function X2B

X2B("C3")        ->  "11000011"
X2B("7")         ->  "0111"
X2B("1 C1")      ->  "000111000001"

You can combine X2B with the functions D2X and C2X to convert numbers or character strings into binary form.
Here are some examples:

Example 7.108. Builtin function X2B

X2B(C2X("C3"x))  ->  "11000011"
X2B(D2X("129"))  ->  "10000001"
X2B(D2X("12"))   ->  "1100"