Logo Search packages:      
Sourcecode: icu version File versions

Collator::EComparisonResult RuleBasedCollator::compare ( const UChar source,
int32_t  sourceLength,
const UChar target,
int32_t  targetLength 
) const [virtual]

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:

 .       UChar ABC[] = {0x41, 0x42, 0x43, 0};  // = "ABC"
 .       UChar abc[] = {0x61, 0x62, 0x63, 0};  // = "abc"
 .       UErrorCode status = U_ZERO_ERROR;
 .       Collator *myCollation =
 .                         Collator::createInstance(Locale::US, 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:
sourcethe source string array to be compared with.
sourceLengththe length of the source string array. If this value is equal to -1, the string array is null-terminated.
targetthe string that is to be compared with the source string.
targetLengththe 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 overload with UErrorCode&

Reimplemented from Collator.

Definition at line 353 of file tblcoll.cpp.

References getEComparisonResult(), and ucollator.

{
    return  getEComparisonResult(ucol_strcoll(ucollator, source, sourceLength,
                                                         target, targetLength));
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index