Product SiteDocumentation Site

1.10.4.2. Hexadecimal Strings

A hexadecimal string is a literal string, expressed using a hexadecimal notation of its encoding. It is any sequence of zero or more hexadecimal digits (0-9, a-f, A-F), grouped in pairs. A single leading 0 is assumed, if necessary, at the beginning of the string to make an even number of hexadecimal digits. The groups of digits are optionally separated by one or more whitespace characters, and the whole sequence is delimited by single or double quotation marks and immediately followed by the symbol X or x. Neither x nor X can be part of a longer symbol. The whitespace characters, which can only be byte boundaries (and not at the beginning or end of the string), are to improve readability. The language processor ignores them.
A hexadecimal string is a literal string formed by packing the hexadecimal digits given. Packing the hexadecimal digits removes whitespace and converts each pair of hexadecimal digits into its equivalent character, for example, "41"X to A.
Hexadecimal strings let you include characters in a program even if you cannot directly enter the characters themselves. These are valid hexadecimal strings:

Example 1.7. Valid hexadecimal strings

"ABCD"x
"1d ec f8"X
"1 d8"x

Note

A hexadecimal string is not a representation of a number. It is an escape mechanism that lets a user describe a character in terms of its encoding (and, therefore, is machine-dependent). In ASCII, "20"X is the encoding for a blank. In every case, a string of the form "....."x is an alternative to a straightforward string. In ASCII "41"x and "A" are identical, as are "20"x and a blank, and must be treated identically.
The packed length of a hexadecimal string (the string with whitespace removed) is unlimited.