Using national-character figurative constants
You can use the figurative
constant ALL
national-literal in a context that requires national characters. ALL
national-literal represents
all or part of the string that is generated by successive concatenations
of the encoding units that make up the national literal.
About this task
You can use the figurative constants QUOTE
, SPACE
, HIGH-VALUE
, LOW-VALUE
, or ZERO
in
a context that requires national characters, such as a MOVE
statement,
an implicit move, or a relation condition that has national operands.
In these contexts, the figurative constant represents a national-character
(UTF-16) value.
When you use the figurative constant HIGH-VALUE
in
a context that requires national characters, its value is NX'FFFF'
.
When you use LOW-VALUE
in a context that requires
national characters, its value is NX'0000'
. You can use HIGH-VALUE
or LOW-VALUE
in
a context that requires national characters only if the NCOLLSEQ(BIN)
compiler
option is in effect.
Restrictions: You
must not use HIGH-VALUE
or the value assigned from HIGH-VALUE
in
a way that results in conversion of the value from one data representation
to another (for example, between USAGE DISPLAY
and USAGE
NATIONAL
, or between ASCII and EBCDIC when
the CHAR(EBCDIC)
compiler option is in effect). X'FF'
(the
value of HIGH-VALUE
in an alphanumeric context when
the EBCDIC collating sequence is being used) does not represent a
valid EBCDIC or ASCII character, and NX'FFFF'
does
not represent a valid national character. Conversion of such a value to another representation
results in a substitution character being used (not X'FF'
or NX'FFFF'
).
Consider the following example:
01 natl-data PIC NN Usage National.
01 alph-data PIC XX.
. . .
MOVE HIGH-VALUE TO natl-data, alph-data
IF natl-data = alph-data. . .
The IF
statement above
evaluates as false even though each of its operands was set to HIGH-VALUE
.
Before an elementary alphanumeric operand is compared to a national
operand, the alphanumeric operand is treated as though it were moved
to a temporary national data item, and the alphanumeric characters
are converted to the corresponding national characters. When X'FF'
is
converted to UTF-16, however, the UTF-16 item gets a substitution
character value and so does not compare equally to NX'FFFF'
.
Converting to or from national (Unicode) representation
Comparing national (UTF-16) data
CHAR
NCOLLSEQ
Figurative constants (COBOL for Linux on x86 Language Reference)
DISPLAY-OF (COBOL for Linux on x86 Language Reference)