Function

CFStringFold

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

Declaration

void CFStringFold(CFMutableStringRef theString, CFStringCompareFlags theFlags, CFLocaleRef theLocale);

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

CFStringAppend

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

CFStringAppendCharacters

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

CFStringAppendCString

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

CFStringAppendFormat

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

CFStringAppendFormatAndArguments

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

CFStringAppendPascalString

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

CFStringCapitalize

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

CFStringCreateMutable

Creates an empty CFMutableString object.

CFStringCreateMutableCopy

Creates a mutable copy of a string.

CFStringCreateMutableWithExternalCharactersNoCopy

Creates a CFMutableString object whose Unicode character buffer is controlled externally.

CFStringDelete

Deletes a range of characters in a string.

CFStringFindAndReplace

Replaces all occurrences of a substring within a given range.

CFStringInsert

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

CFStringLowercase

Changes all uppercase alphabetical characters in a CFMutableString to lowercase.

CFStringNormalize

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

CFStringPad

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

CFStringReplace

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

CFStringReplaceAll

Replaces all characters of a CFMutableString object with other characters.

CFStringSetExternalCharactersNoCopy

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

CFStringTransform

Perform in-place transliteration on a mutable string.

CFStringTrim

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

CFStringTrimWhitespace

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

CFStringUppercase

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