Comparing two class national operands
You can compare the character values of two operands of class national.
About this task
Either operand (or both) can be any of the following types of items:
- A national group
- An elementary category national or national-edited data item
- A numeric-edited data item that has
USAGE NATIONAL
One of the operands can instead be a national literal or a national intrinsic function.
Use
the NCOLLSEQ
compiler option to determine which type
of comparison to perform:
-
NCOLLSEQ(BINARY)
- When you compare two class national operands of the same length, they are
determined to be equal if all pairs of the corresponding characters are equal. Otherwise, comparison
of the binary values of the first pair of unequal characters determines the operand with the larger
binary value.
When you compare operands of unequal lengths, the shorter operand is treated as if it were padded on the right with default UTF-16 space characters (
NX'2000'
) to the length of the longer operand. -
NCOLLSEQ(LOCALE)
- When you use a locale-based comparison, the operands are compared
by using the algorithm for collation order that is associated with
the locale in effect. Trailing spaces are truncated from the operands,
except that an operand that consists of all spaces is truncated to
a single space.
When you compare operands of unequal lengths, the shorter operand is not extended with spaces because such an extension could alter the expected results for the locale.
The PROGRAM
COLLATING SEQUENCE
clause
does not affect the comparison of two class national
operands.