Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

National literals

A national literal may describe up to 90 characters. In the case of a national literal, the opening literal delimiter consisting of the letter N followed by a quotation mark is provided to distinguish alphanumeric literals. As a COBOL source text is available in EBCDIC, only EBCDIC characters can be written as the literal content. The compiler automatically replaces these by the corresponding UTF-16 representation.

In addition, there is also the hexadecimal variant, introduced by the two letters NX, followed by a quotation mark. Here every character must be written directly in its UTF-16 representation in the form of 4 hexadecimal digits. This also enables national literals to be specified which have no equivalent in the EBCDIC character set.

Example 12-13

N'AB '
NX"004100420020"

both describe the same string in UTF-16 representation.


The figurative constants are a particular form of literal.
There are also national forms of these:

  • The keyword ALL followed by a national literal.

  • SPACE, QUOTE, ZERO, HIGH-VALUE and LOW-VALUE which are defined as keywords. Depending on the context in which they are used, they stand for the corresponding alphanumeric or national literals.

Example 12-14

01 alfa PIC X.
01 nat PIC N.
MOVE SPACE to alfa, nat.

supplies the alfa item with an alphanumeric blank (X'40') and the nat item with a national blank (X'0020').