Basic alphanumeric literals
Basic alphanumeric literals can contain any character in a single-byte EBCDIC character set.
The following format is for a basic alphanumeric literal:
Format 1: Basic alphanumeric literals |
---|
|
The enclosing quotation marks or apostrophes are excluded from the literal when the program is compiled.
""
) or a pair of apostrophes
(''
), respectively, when it is the character used
as the opening delimiter. For example:"THIS ISN""T WRONG"
returnsTHIS ISN"T WRONG
.'THIS ISN''T WRONG'
returnsTHIS ISN'T WRONG
.
This is a similar concept to an escape character or escape sequence that is used to represent certain special characters within literals in other programming languages. Other than the quotation mark and apostrophe, the only other consideration you need to give to special characters in literals is to Double-Byte Character Set (DBCS) literals, which are needed for national languages that contain unique characters or symbols. For details, See DBCS literals.
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.
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.)