Contents

CFStringFold(_:_:_:)

Folds a given string into the form specified by optional flags.

Declaration

func CFStringFold(_ theString: CFMutableString!, _ theFlags: CFStringCompareFlags, _ theLocale: CFLocale!)

Parameters

  • theString:

    The string which is to be folded. If this parameter is not a valid mutable CFString, the behavior is undefined.

  • theFlags:

    The equivalency flags which describes the character folding form. See “String Comparison Flags” in Cfstring for possible values. Only those flags containing the word “insensitive” are recognized; other flags are ignored.

    Folding with kCFCompareCaseInsensitive removes case distinctions in accordance with the mapping specified by ftp://ftp.unicode.org/Public/UNIDATA/CaseFolding.txt. Folding with kCFCompareDiacriticInsensitive removes distinctions of accents and other diacritics. Folding with kCFCompareWidthInsensitive removes character width distinctions by mapping characters in the range U+FF00-U+FFEF to their ordinary equivalents.

  • theLocale:

    The locale to use for the operation. NULL specifies the canonical locale (the return value from Cflocalegetsystem()).

    The locale argument affects the case mapping algorithm. For example, for the Turkish locale, case-insensitive compare matches “I” to “ı” (Unicode code point U+0131, Latin Small Dotless I), not the normal “i” character.

Discussion

Character foldings are operations that convert any of a set of characters sharing similar semantics into a single representative from that set.

You can use this function to preprocess strings that are to be compared, searched, or indexed. Note that folding does not include normalization, so you must use CFStringNormalize(_:_:) in addition to CFStringFold in order to obtain the effect of kCFCompareNonliteral.

See Also

CFMutableString Miscellaneous Functions