Rational Developer for System z
COBOL for Windows, Version 7.5, Programming Guide


Comparing two class national operands

You can compare the character values of two operands of class national.

Either operand (or both) can be any of the following types of items:

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'0020') 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.

related concepts
National groups

related tasks
Using national groups

related references
NCOLLSEQ
National comparisons (COBOL for Windows Language Reference)


Terms of use | Feedback

Copyright IBM Corporation 1996, 2008.
This information center is powered by Eclipse technology. (http://www.eclipse.org)