<!--
{
  "documentType" : "article",
  "framework" : "CoreFoundation",
  "identifier" : "/documentation/CoreFoundation/string-comparison-flags",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "String Comparison Flags"
}
-->

# String Comparison Flags

Flags that specify how string comparisons are performed.

## Discussion

These constants are flags intended for use in the comparison-option parameters in comparison functions such as [`CFStringCompare(_:_:_:)`](/documentation/CoreFoundation/CFStringCompare(_:_:_:)). If you want to request multiple options, combine them with a bitwise-OR operation.

## Topics

### Constants

[`static var compareCaseInsensitive: CFStringCompareFlags`](/documentation/CoreFoundation/CFStringCompareFlags/compareCaseInsensitive)

Specifies that the comparison should ignore differences in case between alphabetical characters.

[`static var compareBackwards: CFStringCompareFlags`](/documentation/CoreFoundation/CFStringCompareFlags/compareBackwards)

Specifies that the comparison should start at the last elements of the entities being compared (for example, strings or arrays).

[`static var compareAnchored: CFStringCompareFlags`](/documentation/CoreFoundation/CFStringCompareFlags/compareAnchored)

Performs searching only on characters at the beginning or end of the range.

[`static var compareNonliteral: CFStringCompareFlags`](/documentation/CoreFoundation/CFStringCompareFlags/compareNonliteral)

Specifies that loose equivalence is acceptable, especially as pertains to diacritical marks.

[`static var compareLocalized: CFStringCompareFlags`](/documentation/CoreFoundation/CFStringCompareFlags/compareLocalized)

Specifies that the comparison should take into account differences related to locale, such as the thousands separator character.

[`static var compareNumerically: CFStringCompareFlags`](/documentation/CoreFoundation/CFStringCompareFlags/compareNumerically)

Specifies that represented numeric values should be used as the basis for comparison and not the actual character values.

[`static var compareDiacriticInsensitive: CFStringCompareFlags`](/documentation/CoreFoundation/CFStringCompareFlags/compareDiacriticInsensitive)

Specifies that the comparison should ignore diacritic markers.

[`static var compareWidthInsensitive: CFStringCompareFlags`](/documentation/CoreFoundation/CFStringCompareFlags/compareWidthInsensitive)

Specifies that the comparison should ignore width differences.

[`static var compareForcedOrdering: CFStringCompareFlags`](/documentation/CoreFoundation/CFStringCompareFlags/compareForcedOrdering)

Specifies that the comparison is forced to return either `kCFCompareLessThan` or `kCFCompareGreaterThan` if the strings are equivalent but not strictly equal.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)