Showing content from https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classicu_1_1RuleBasedCollator.html below:
ICU 77.1: icu::RuleBasedCollator Class Reference
RuleBasedCollator (const UnicodeString &rules, UErrorCode &status) RuleBasedCollator constructor. More...
RuleBasedCollator (const UnicodeString &rules, ECollationStrength collationStrength, UErrorCode &status) RuleBasedCollator constructor. More...
RuleBasedCollator (const UnicodeString &rules, UColAttributeValue decompositionMode, UErrorCode &status) RuleBasedCollator constructor. More...
RuleBasedCollator (const UnicodeString &rules, ECollationStrength collationStrength, UColAttributeValue decompositionMode, UErrorCode &status) RuleBasedCollator constructor. More...
RuleBasedCollator (const UnicodeString &rules, UParseError &parseError, UnicodeString &reason, UErrorCode &errorCode) TODO: document & propose as public API. More...
RuleBasedCollator (const RuleBasedCollator &other) Copy constructor. More...
RuleBasedCollator (const uint8_t *bin, int32_t length, const RuleBasedCollator *base, UErrorCode &status) Opens a collator from a collator binary image created using cloneBinary. More...
virtual ~RuleBasedCollator () Destructor. More...
RuleBasedCollator & operator= (const RuleBasedCollator &other) Assignment operator. More...
virtual bool operator== (const Collator &other) const override Returns true if argument is the same as this object. More...
virtual RuleBasedCollator * clone () const override Makes a copy of this object. More...
virtual CollationElementIterator * createCollationElementIterator (const UnicodeString &source) const Creates a collation element iterator for the source string. More...
virtual CollationElementIterator * createCollationElementIterator (const CharacterIterator &source) const Creates a collation element iterator for the source. More...
virtual UCollationResult compare (const UnicodeString &source, const UnicodeString &target, UErrorCode &status) const override The comparison function compares the character data stored in two different strings. More...
virtual UCollationResult compare (const UnicodeString &source, const UnicodeString &target, int32_t length, UErrorCode &status) const override Does the same thing as compare but limits the comparison to a specified length. More...
virtual UCollationResult compare (const char16_t *source, int32_t sourceLength, const char16_t *target, int32_t targetLength, UErrorCode &status) const override The comparison function compares the character data stored in two different string arrays. More...
virtual UCollationResult compare (UCharIterator &sIter, UCharIterator &tIter, UErrorCode &status) const override Compares two strings using the Collator. More...
virtual UCollationResult compareUTF8 (const StringPiece &source, const StringPiece &target, UErrorCode &status) const override Compares two UTF-8 strings using the Collator. More...
virtual CollationKey & getCollationKey (const UnicodeString &source, CollationKey &key, UErrorCode &status) const override Transforms the string into a series of characters that can be compared with CollationKey.compare(). More...
virtual CollationKey & getCollationKey (const char16_t *source, int32_t sourceLength, CollationKey &key, UErrorCode &status) const override Transforms a specified region of the string into a series of characters that can be compared with CollationKey.compare. More...
virtual int32_t hashCode () const override Generates the hash code for the rule-based collation object. More...
virtual Locale getLocale (ULocDataLocaleType type, UErrorCode &status) const override Gets the locale of the Collator. More...
const UnicodeString & getRules () const Gets the tailoring rules for this collator. More...
virtual void getVersion (UVersionInfo info) const override Gets the version information for a Collator. More...
int32_t getMaxExpansion (int32_t order) const Returns the maximum length of any expansion sequences that end with the specified comparison order. More...
virtual UClassID getDynamicClassID () const override Returns a unique class ID POLYMORPHICALLY. More...
uint8_t * cloneRuleData (int32_t &length, UErrorCode &status) const Do not use this method: The caller and the ICU library might use different heaps. More...
int32_t cloneBinary (uint8_t *buffer, int32_t capacity, UErrorCode &status) const Creates a binary image of a collator. More...
void getRules (UColRuleOption delta, UnicodeString &buffer) const Returns current rules. More...
virtual void setAttribute (UColAttribute attr, UColAttributeValue value, UErrorCode &status) override Universal attribute setter. More...
virtual UColAttributeValue getAttribute (UColAttribute attr, UErrorCode &status) const override Universal attribute getter. More...
virtual Collator & setMaxVariable (UColReorderCode group, UErrorCode &errorCode) override Sets the variable top to the top of the specified reordering group. More...
virtual UColReorderCode getMaxVariable () const override Returns the maximum reordering group whose characters are affected by UCOL_ALTERNATE_HANDLING. More...
virtual uint32_t setVariableTop (const char16_t *varTop, int32_t len, UErrorCode &status) override Sets the variable top to the primary weight of the specified string. More...
virtual uint32_t setVariableTop (const UnicodeString &varTop, UErrorCode &status) override Sets the variable top to the primary weight of the specified string. More...
virtual void setVariableTop (uint32_t varTop, UErrorCode &status) override Sets the variable top to the specified primary weight. More...
virtual uint32_t getVariableTop (UErrorCode &status) const override Gets the variable top value of a Collator. More...
virtual UnicodeSet * getTailoredSet (UErrorCode &status) const override Get a UnicodeSet that contains all the characters and sequences tailored in this collator. More...
virtual int32_t getSortKey (const UnicodeString &source, uint8_t *result, int32_t resultLength) const override Get the sort key as an array of bytes from a UnicodeString. More...
virtual int32_t getSortKey (const char16_t *source, int32_t sourceLength, uint8_t *result, int32_t resultLength) const override Get the sort key as an array of bytes from a char16_t buffer. More...
virtual int32_t getReorderCodes (int32_t *dest, int32_t destCapacity, UErrorCode &status) const override Retrieves the reordering codes for this collator. More...
virtual void setReorderCodes (const int32_t *reorderCodes, int32_t reorderCodesLength, UErrorCode &status) override Sets the ordering of scripts for this collator. More...
virtual UCollationResult internalCompareUTF8 (const char *left, int32_t leftLength, const char *right, int32_t rightLength, UErrorCode &errorCode) const override Implements ucol_strcollUTF8(). More...
virtual int32_t internalGetShortDefinitionString (const char *locale, char *buffer, int32_t capacity, UErrorCode &status) const override Get the short definition string for a collator. More...
virtual int32_t internalNextSortKeyPart (UCharIterator *iter, uint32_t state[2], uint8_t *dest, int32_t count, UErrorCode &errorCode) const override Implements ucol_nextSortKeyPart(). More...
RuleBasedCollator () Only for use in ucol_openRules(). More...
const char * internalGetLocaleID (ULocDataLocaleType type, UErrorCode &errorCode) const Implements ucol_getLocaleByType(). More...
void internalGetContractionsAndExpansions (UnicodeSet *contractions, UnicodeSet *expansions, UBool addPrefixes, UErrorCode &errorCode) const Implements ucol_getContractionsAndExpansions(). More...
void internalAddContractions (UChar32 c, UnicodeSet &set, UErrorCode &errorCode) const Adds the contractions that start with character c to the set. More...
void internalBuildTailoring (const UnicodeString &rules, int32_t strength, UColAttributeValue decompositionMode, UParseError *outParseError, UnicodeString *outReason, UErrorCode &errorCode) Implements from-rule constructors, and ucol_openRules(). More...
void internalGetCEs (const UnicodeString &str, UVector64 &ces, UErrorCode &errorCode) const Appends the CEs for the string to the vector. More...
virtual EComparisonResult compare (const UnicodeString &source, const UnicodeString &target) const The comparison function compares the character data stored in two different strings. More...
virtual UCollationResult compare (const UnicodeString &source, const UnicodeString &target, UErrorCode &status) const=0 The comparison function compares the character data stored in two different strings. More...
virtual EComparisonResult compare (const UnicodeString &source, const UnicodeString &target, int32_t length) const Does the same thing as compare but limits the comparison to a specified length. More...
virtual UCollationResult compare (const UnicodeString &source, const UnicodeString &target, int32_t length, UErrorCode &status) const=0 Does the same thing as compare but limits the comparison to a specified length. More...
virtual EComparisonResult compare (const char16_t *source, int32_t sourceLength, const char16_t *target, int32_t targetLength) const The comparison function compares the character data stored in two different string arrays. More...
virtual UCollationResult compare (const char16_t *source, int32_t sourceLength, const char16_t *target, int32_t targetLength, UErrorCode &status) const=0 The comparison function compares the character data stored in two different string arrays. More...
virtual UCollationResult compare (UCharIterator &sIter, UCharIterator &tIter, UErrorCode &status) const Compares two strings using the Collator. More...
virtual ~Collator () Destructor. More...
virtual bool operator!= (const Collator &other) const Returns true if "other" is not the same as "this". More...
virtual EComparisonResult compare (const UnicodeString &source, const UnicodeString &target) const The comparison function compares the character data stored in two different strings. More...
virtual EComparisonResult compare (const UnicodeString &source, const UnicodeString &target, int32_t length) const Does the same thing as compare but limits the comparison to a specified length. More...
virtual EComparisonResult compare (const char16_t *source, int32_t sourceLength, const char16_t *target, int32_t targetLength) const The comparison function compares the character data stored in two different string arrays. More...
UBool greater (const UnicodeString &source, const UnicodeString &target) const Convenience method for comparing two strings based on the collation rules. More...
UBool greaterOrEqual (const UnicodeString &source, const UnicodeString &target) const Convenience method for comparing two strings based on the collation rules. More...
UBool equals (const UnicodeString &source, const UnicodeString &target) const Convenience method for comparing two strings based on the collation rules. More...
auto equal_to () const Creates a comparison function object that uses this collator. More...
auto greater () const Creates a comparison function object that uses this collator. More...
auto less () const Creates a comparison function object that uses this collator. More...
auto not_equal_to () const Creates a comparison function object that uses this collator. More...
auto greater_equal () const Creates a comparison function object that uses this collator. More...
auto less_equal () const Creates a comparison function object that uses this collator. More...
virtual ECollationStrength getStrength () const Determines the minimum strength that will be used in comparison or transformation. More...
virtual void setStrength (ECollationStrength newStrength) Sets the minimum strength to be used in comparison or transformation. More...
virtual Collator * safeClone () const Same as clone(). More...
UCollator * toUCollator () const UCollator * toUCollator () const virtual ~UObject () Destructor. More...
static UClassID getStaticClassID () Returns the class ID for this class. More...
static RuleBasedCollator * rbcFromUCollator (UCollator *uc) static const RuleBasedCollator * rbcFromUCollator (const UCollator *uc) static Collator * createInstance (UErrorCode &err) Creates the Collator object for the current default locale. More...
static Collator * createInstance (const Locale &loc, UErrorCode &err) Gets the collation object for the desired locale. More...
static int32_t getEquivalentReorderCodes (int32_t reorderCode, int32_t *dest, int32_t destCapacity, UErrorCode &status) Retrieves the reorder codes that are grouped with the given reorder code. More...
static UnicodeString & getDisplayName (const Locale &objectLocale, const Locale &displayLocale, UnicodeString &name) Get name of the object for the desired Locale, in the desired language. More...
static UnicodeString & getDisplayName (const Locale &objectLocale, UnicodeString &name) Get name of the object for the desired Locale, in the language of the default locale. More...
static const Locale * getAvailableLocales (int32_t &count) Get the set of Locales for which Collations are installed. More...
static StringEnumeration * getAvailableLocales () Return a StringEnumeration over the locales available at the time of the call, including registered locales. More...
static StringEnumeration * getKeywords (UErrorCode &status) Create a string enumerator of all possible keywords that are relevant to collation. More...
static StringEnumeration * getKeywordValues (const char *keyword, UErrorCode &status) Given a keyword, create a string enumeration of all values for that keyword that are currently in use. More...
static StringEnumeration * getKeywordValuesForLocale (const char *keyword, const Locale &locale, UBool commonlyUsed, UErrorCode &status) Given a key and a locale, returns an array of string values in a preferred order that would make a difference. More...
static Locale getFunctionalEquivalent (const char *keyword, const Locale &locale, UBool &isAvailable, UErrorCode &status) Return the functionally equivalent locale for the given requested locale, with respect to given keyword, for the collation service. More...
static URegistryKey registerInstance (Collator *toAdopt, const Locale &locale, UErrorCode &status) Register a new Collator. More...
static URegistryKey registerFactory (CollatorFactory *toAdopt, UErrorCode &status) Register a new CollatorFactory. More...
static UBool unregister (URegistryKey key, UErrorCode &status) Unregister a previously-registered Collator or CollatorFactory using the key returned from the register call. More...
static int32_t getBound (const uint8_t *source, int32_t sourceLength, UColBoundMode boundType, uint32_t noOfLevels, uint8_t *result, int32_t resultLength, UErrorCode &status) Produce a bound for a given sortkey and a number of levels. More...
static Collator * fromUCollator (UCollator *uc) static const Collator * fromUCollator (const UCollator *uc) enum ECollationStrength {
PRIMARY = UCOL_PRIMARY , SECONDARY = UCOL_SECONDARY , TERTIARY = UCOL_TERTIARY , QUATERNARY = UCOL_QUATERNARY ,
IDENTICAL = UCOL_IDENTICAL
} Base letter represents a primary difference. More...
enum EComparisonResult { LESS = UCOL_LESS , EQUAL = UCOL_EQUAL , GREATER = UCOL_GREATER } LESS is returned if source string is compared to be less than target string in the compare() method. More...
The RuleBasedCollator class provides the implementation of Collator, using data-driven tables.
The user can create a customized table-based collation.
For more information about the collation service see the User Guide.
Collation service provides correct sorting orders for most locales supported in ICU. If specific data for a locale is not available, the orders eventually falls back to the CLDR root sort order.
Sort ordering may be customized by providing your own set of rules. For more on this subject see the Collation Customization section of the User Guide.
Note, RuleBasedCollator is not to be subclassed.
-
See also
-
Collator
Definition at line 115 of file tblcoll.h.
The comparison function compares the character data stored in two different string arrays.
Returns information about whether a string array is less than, greater than or equal to another string array.
Example of use:
. char16_t ABC[] = {0x41, 0x42, 0x43, 0}; // = "ABC"
. char16_t abc[] = {0x61, 0x62, 0x63, 0}; // = "abc"
. UErrorCode status = U_ZERO_ERROR;
. Collator *myCollation =
. Collator::createInstance(Locale::getUS(), status);
. if (U_FAILURE(status)) return;
. myCollation->setStrength(Collator::PRIMARY);
. // result would be Collator::EQUAL ("abc" == "ABC")
. // (no primary difference between "abc" and "ABC")
. Collator::EComparisonResult result =
. myCollation->compare(abc, 3, ABC, 3);
. myCollation->setStrength(Collator::TERTIARY);
. // result would be Collator::LESS ("abc" <<< "ABC")
. // (with tertiary difference between "abc" and "ABC")
. result = myCollation->compare(abc, 3, ABC, 3);
-
Parameters
-
source the source string array to be compared with. sourceLength the length of the source string array. If this value is equal to -1, the string array is null-terminated. target the string that is to be compared with the source string. targetLength the length of the target string array. If this value is equal to -1, the string array is null-terminated.
-
Returns
-
Returns a byte value. GREATER if source is greater than target; EQUAL if source is equal to target; LESS if source is less than target
-
Deprecated:
-
ICU 2.6 use the overload with UErrorCode &
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4