Hexadecimal notation for alphanumeric literals
Hexadecimal notation can be used for alphanumeric literals.
Hexadecimal notation has the following format:
Format 2: Hexadecimal notation for alphanumeric literals |
---|
|
-
X"
orX'
- The opening delimiter for the hexadecimal notation of an alphanumeric literal.
-
"
or'
- The closing delimiter for the hexadecimal notation of an alphanumeric literal. If a quotation mark is used in the opening delimiter, a quotation mark must be used as the closing delimiter. Similarly, if an apostrophe is used in the opening delimiter, an apostrophe must be used as the closing delimiter.
Hexadecimal digits are characters in the range '0' to '9', 'a' to 'f', and 'A' to 'F', inclusive. Two hexadecimal digits represent one character in a single-byte character set (EBCDIC or ASCII). Four hexadecimal digits represent one character in a DBCS character set. For UTF-8 or EUC, the number of hexadecimal digits that represent a character depends on the byte length of the character. An even number of hexadecimal digits must be specified. The maximum length of a hexadecimal literal is 320 hexadecimal digits.
The continuation rules are the same
as those for any alphanumeric literal. The opening delimiter (X"
or X'
)
cannot be split across lines.
An alphanumeric literal in hexadecimal notation has data class and category alphanumeric. The compiler converts the hexadecimal notation into the normal characters of an alphanumeric literal. Hexadecimal notation for alphanumeric literals can be used anywhere alphanumeric literals can be used.
However, alphanumeric literals in hexadecimal notation are interpreted as EBCDIC if the CHAR(EBCDIC) compiler option is in effect, whereas basic alphanumeric literals are always interpreted in the (ASCII-based) code page of the current locale. See CHAR in the COBOL for Linux® on x86 Programming Guide for more information on the CHAR(EBCDIC) compiler option.
Usage note: Use hexadecimal notation to express control characters X'00' through X'1F' within an alphanumeric literal. Results are unpredictable if you specify these control characters in a basic alphanumeric literal.