Basic alphanumeric literals can contain only single-byte or multibyte characters.
The following is the format for a basic alphanumeric literal:
| Format 1: Basic alphanumeric literals |
|---|
"single-byte or multibyte characters" 'single-byte or multibyte characters' |
The enclosing quotation marks or apostrophes are excluded from the literal when the program is compiled.
An embedded quotation mark or apostrophe must be represented by a pair of quotation marks ("") or a pair of apostrophes (''), respectively, when it is the character used as the opening delimiter. For example:
"THIS ISN""T WRONG" 'THIS ISN''T WRONG'
The delimiter character used as the opening delimiter for a literal must be used as the closing delimiter for that literal. For example:
'THIS IS RIGHT' "THIS IS RIGHT" 'THIS IS WRONG"
You can use apostrophes or quotation marks as the literal delimiters independent of the APOST/QUOTE compiler option.
Any punctuation characters included within an alphanumeric literal are part of the value of the literal.
"single-byte or multibyte characters" can be any characters represented in the code page indicated by the locale in effect at compile time.
The maximum length of an alphanumeric literal is 160 bytes. The minimum length is 1 byte.
Alphanumeric literals are in the alphanumeric data class and category. (Data classes and categories are described in Classes and categories of data.)
See SOSI in the COBOL for AIX Programming Guide which describes special treatment of values X'1E' and X'1F' in alphanumeric literals, and additional programming restrictions for alphanumeric literals containing these characters when the SOSI compiler option is in effect.
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.