Compares a range of the characters in one string with another string using a given locale.


CFComparisonResult CFStringCompareWithOptionsAndLocale(CFStringRef theString1, CFStringRef theString2, CFRange rangeToCompare, CFStringCompareFlags compareOptions, CFLocaleRef locale);



The first string to use in the comparison.


The second string to use in the comparison. The full range of this string is used.


The range of characters in theString1 to be used in the comparison to theString2. To use the whole string, pass the range CFRangeMake(0, CFStringGetLength(theString1)). The specified range must not exceed the bounds of the string.


Flags that select different types of comparisons, such as case-insensitive comparison and non-literal comparison. See String Comparison Flags for the available flags.

Specifying the kCFCompareBackwards or kCFCompareAnchored option has no effect.

Specifying the kCFCompareLocalized option and passing NULL for locale causes the current locale (the return value of CFLocaleCopyCurrent) to be used.


The locale to use for the comparison, which affects both equality and ordering algorithms. For example, in some locales, accented characters are ordered immediately after the base; other locales order them after “z”.

If NULL and the kCFCompareLocalized option is not specified for compareOptions, the comparison is nonlocalized.

Return Value

A CFComparisonResult value that indicates whether theString1 is equal to, less than, or greater than theString2.

See Also

Comparing Strings


Compares one string with another string.


Compares a range of the characters in one string with that of another string.


Determines if the character data of a string begin with a specified sequence of characters.


Determines if a string ends with a specified sequence of characters.