A nonnumeric literal is a character string delimited at both ends by quotation marks
or apostrophes
and consisting of any allowable character in the computer's character set. In native COBOL, nonnumeric literals may be between 1 and 8192 bytes in length. When compiling for .NET COBOL, the minimum length of a nonnumeric literal is 0. In most cases, a literal with zero length is equivalent to a single character literal with value space, except where the literal is the source of an assignment to a string object, or is a parameter to a method expecting a string parameter, where the distinction is important.
Whether quotation marks
or apostrophes
are used as delimiters, the presence of that delimiter character within the character string can be represented by two contiguous occurrences. The presence of the character that is not serving as the delimiter is represented by a single occurrence. The value of a nonnumeric literal in the run-time element is the string of characters itself, except:
All other punctuation characters are part of the value of the nonnumeric literal rather than separators; all nonnumeric literals are category alphanumeric. (See the topic The PICTURE Clause.)
In addition, hexadecimal binary values can be attributed to nonnumeric literals by expressing literals as: X"nn", where each n is a hexadecimal digit in the set 0 through 9, A through F; nn can be repeated up to 160 times, but the number of hexadecimal digits must be even.
The number of hexadecimal digits may be odd.
In addition, a nonnumeric literal can be null-terminated (i.e. have a null byte x"00" at the end of the literal) by expressing it as: Z"string", where string is a nonnumeric literal.