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


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



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


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 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.


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.


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

func CFStringAppend(CFMutableString!, CFString!)

Appends the characters of a string to those of a CFMutableString object.

func CFStringAppendCharacters(CFMutableString!, UnsafePointer<UniChar>!, CFIndex)

Appends a buffer of Unicode characters to the character contents of a CFMutableString object.

func CFStringAppendCString(CFMutableString!, UnsafePointer<Int8>!, CFStringEncoding)

Appends a C string to the character contents of a CFMutableString object.

func CFStringAppendFormatAndArguments(CFMutableString!, CFDictionary!, CFString!, CVaListPointer)

Appends a formatted string to the character contents of a CFMutableString object.

func CFStringAppendPascalString(CFMutableString!, ConstStr255Param!, CFStringEncoding)

Appends a Pascal string to the character contents of a CFMutableString object.

func CFStringCapitalize(CFMutableString!, CFLocale!)

Changes the first character in each word of a string to uppercase (if it is a lowercase alphabetical character).

func CFStringDelete(CFMutableString!, CFRange)

Deletes a range of characters in a string.

func CFStringInsert(CFMutableString!, CFIndex, CFString!)

Inserts a string at a specified location in the character buffer of a CFMutableString object.

func CFStringLowercase(CFMutableString!, CFLocale!)

Changes all uppercase alphabetical characters in a CFMutableString to lowercase.

func CFStringNormalize(CFMutableString!, CFStringNormalizationForm)

Normalizes the string into the specified form as described in Unicode Technical Report #15.

func CFStringPad(CFMutableString!, CFString!, CFIndex, CFIndex)

Enlarges a string, padding it with specified characters, or truncates the string.

func CFStringReplace(CFMutableString!, CFRange, CFString!)

Replaces part of the character contents of a CFMutableString object with another string.

func CFStringReplaceAll(CFMutableString!, CFString!)

Replaces all characters of a CFMutableString object with other characters.

func CFStringSetExternalCharactersNoCopy(CFMutableString!, UnsafeMutablePointer<UniChar>!, CFIndex, CFIndex)

Notifies a CFMutableString object that its external backing store of Unicode characters has changed.

func CFStringTrim(CFMutableString!, CFString!)

Trims a specified substring from the beginning and end of a CFMutableString object.

func CFStringTrimWhitespace(CFMutableString!)

Trims whitespace from the beginning and end of a CFMutableString object.

func CFStringUppercase(CFMutableString!, CFLocale!)

Changes all lowercase alphabetical characters in a CFMutableString object to uppercase.