Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Internationalization Module User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

6.2 Locale-Sensitive String Comparison

In the Internationalization Module, RWUCollator performs locale-sensitive string comparison. Each RWUCollator is associated with an RWULocale at construction time, in order to take language-specific conventions into account. For example.

If no locale is specified, then the current default locale is used. The locale specifies the default values for a variety of RWUCollator attributes. Collator attributes can be overridden using mutator methods (Section 6.3). The getLocale() method returns the locale upon which a collator is based.

Once you've instantiated an RWUCollator, you can compare two strings according to the dictates of the collator's attributes using the compareTo() method:

The compareTo() method returns:

For example, coté compares less than côte in the English locale, but greater than côte in the French locale:

//1

Creates an RWUCollator based on the English locale.

//2

Compares the two strings.

//3

Creates an RWUCollator based on the French locale.

//4

Compares the two strings.

The output is:

Similarly, the equals() method returns true if two strings compare equal according to the dictates of the collator's attributes; otherwise, false. Thus:

}



Previous fileTop of DocumentContentsIndex pageNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and SourcePro, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.