iOS Developer Library

Developer

CoreFoundation Framework Reference CFMutableString Reference

Options
Deployment Target:

On This Page
Language:

CFMutableString Reference

CFMutableString manages dynamic strings. The basic interface for managing strings is provided by CFString. CFMutableString adds functions to modify the contents of a string.

CFMutableString is “toll-free bridged” with its Cocoa Foundation counterpart, NSMutableString. This means that the Core Foundation type is interchangeable in function or method calls with the bridged Foundation object. Therefore, in a method where you see an NSMutableString * parameter, you can pass in a CFMutableStringRef, and in a function where you see a CFMutableStringRef parameter, you can pass in an NSMutableString instance. This also applies to concrete subclasses of NSMutableString. See Toll-Free Bridged Types in Core Foundation Design Concepts for more information on toll-free bridging.

Functions

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

    Declaration

    Swift

    func CFStringAppend(_ theString: CFMutableString!, _ appendedString: CFString!)

    Objective-C

    void CFStringAppend ( CFMutableStringRef theString, CFStringRef appendedString );

    Parameters

    theString

    The string to which appendedString is appended. If theString is not a CFMutableString object, an assertion is raised.

    appendedString

    The string to append.

    Discussion

    This function reallocates the backing store of theString to accommodate the new length.

    Import Statement

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

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

    Declaration

    Swift

    func CFStringAppendCharacters(_ theString: CFMutableString!, _ chars: UnsafePointer<UniChar>, _ numChars: CFIndex)

    Objective-C

    void CFStringAppendCharacters ( CFMutableStringRef theString, const UniChar *chars, CFIndex numChars );

    Parameters

    theString

    The string to which the characters in chars are appended.

    chars

    A pointer to a buffer of Unicode characters.

    numChars

    The number of Unicode characters in chars.

    Import Statement

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

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

    Declaration

    Swift

    func CFStringAppendCString(_ theString: CFMutableString!, _ cStr: UnsafePointer<Int8>, _ encoding: CFStringEncoding)

    Objective-C

    void CFStringAppendCString ( CFMutableStringRef theString, const char *cStr, CFStringEncoding encoding );

    Parameters

    theString

    The string to which the characters from cStr are appended. If this value is not a CFMutableString object, an assertion is raised.

    cStr

    A pointer to a C string buffer.

    encoding

    The encoding of the characters in cStr.

    Import Statement

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

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

    Declaration

    Objective-C

    void CFStringAppendFormat ( CFMutableStringRef theString, CFDictionaryRef formatOptions, CFStringRef format, ... );

    Parameters

    theString

    The string to which the formatted characters from format are appended. If this value is not a CFMutableString object, an assertion is raised.

    formatOptions

    A dictionary containing formatting options for the string (such as the thousand-separator character, which is dependent on locale). Currently, these options are an unimplemented feature.

    format

    A formatted string with printf-style specifiers.

    ...

    Variable list of the values to be inserted in format.

    Discussion

    A formatted string is one with printf-style format specifiers embedded in the text such as %d (decimal), %f (double), and %@ (Core Foundation object). The subsequent arguments, in order, are substituted for the specifiers in the character data appended to theString. You can also reorder the arguments in the string by using modifiers of the form "n$" with the format specifiers (for example, %2$d).

    For more information on supported specifiers, see the relevant section in String Programming Guide for Core Foundation.

    Import Statement

    Availability

    Available in iOS 2.0 and later.

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

    Declaration

    Swift

    func CFStringAppendFormatAndArguments(_ theString: CFMutableString!, _ formatOptions: CFDictionary!, _ format: CFString!, _ arguments: CVaListPointer)

    Objective-C

    void CFStringAppendFormatAndArguments ( CFMutableStringRef theString, CFDictionaryRef formatOptions, CFStringRef format, va_list arguments );

    Parameters

    theString

    The string to which the formatted characters from format are appended. If this value is not a CFMutableString object, an assertion is raised.

    formatOptions

    A dictionary containing formatting options for the string (such as the thousand-separator character, which is dependent on locale). Currently, these options are an unimplemented feature.

    format

    A formatted string with printf-style specifiers.

    arguments

    List of values to be inserted in format.

    Discussion

    A formatted string is one with printf-style format specifiers embedded in the text such as %d (decimal), %f (double), and %@ (Core Foundation object). The subsequent arguments, in order, are substituted for the specifiers in the character data appended to theString. You can also reorder the arguments in the string by using modifiers of the form "n$" with the format specifiers (for example, %2$d).

    For more information on supported specifiers, see the relevant section in String Programming Guide for Core Foundation.

    Import Statement

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

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

    Declaration

    Swift

    func CFStringAppendPascalString(_ theString: CFMutableString!, _ pStr: ConstStr255Param, _ encoding: CFStringEncoding)

    Objective-C

    void CFStringAppendPascalString ( CFMutableStringRef theString, ConstStr255Param pStr, CFStringEncoding encoding );

    Parameters

    theString

    The string to which the characters in pStr are appended. If this value is not a CFMutableString object, an assertion is raised.

    pStr

    A Pascal string buffer.

    encoding

    The string encoding of the characters in pStr.

    Import Statement

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

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

    Declaration

    Swift

    func CFStringCapitalize(_ theString: CFMutableString!, _ locale: CFLocale!)

    Objective-C

    void CFStringCapitalize ( CFMutableStringRef theString, CFLocaleRef locale );

    Parameters

    theString

    The string to be capitalized. If this value is not a CFMutableString object, an assertion is raised.

    locale

    A locale that specifies a particular language or region. Prior to OS X v10.3, this parameter was an untyped pointer and not used.

    Import Statement

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

  • Creates an empty CFMutableString object.

    Declaration

    Swift

    func CFStringCreateMutable(_ alloc: CFAllocator!, _ maxLength: CFIndex) -> CFMutableString!

    Objective-C

    CFMutableStringRef CFStringCreateMutable ( CFAllocatorRef alloc, CFIndex maxLength );

    Parameters

    alloc

    The allocator to use to allocate memory for the new string. Pass NULL or kCFAllocatorDefault to use the current default allocator.

    maxLength

    The maximum number of Unicode characters that can be stored by the returned string. Pass 0 if there should be no character limit. Note that initially the string still has a length of 0; this parameter simply specifies what the maximum size is. CFMutableString might try to optimize its internal storage by paying attention to this value.

    Return Value

    A new empty CFMutableString object or NULL if there was a problem creating the object. Ownership follows the Create Rule in Memory Management Programming Guide for Core Foundation.

    Discussion

    This function creates an empty (that is, content-less) CFMutableString object. You can add character data to this object with any of the CFStringAppend... functions, and thereafter you can insert, delete, replace, pad, and trim characters with the appropriate CFString functions. If the maxLength parameter is greater than 0, any attempt to add characters beyond this limit results in a run-time error.

    Import Statement

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

  • Creates a mutable copy of a string.

    Declaration

    Swift

    func CFStringCreateMutableCopy(_ alloc: CFAllocator!, _ maxLength: CFIndex, _ theString: CFString!) -> CFMutableString!

    Objective-C

    CFMutableStringRef CFStringCreateMutableCopy ( CFAllocatorRef alloc, CFIndex maxLength, CFStringRef theString );

    Parameters

    alloc

    The allocator to use to allocate memory for the new string. Pass NULL or kCFAllocatorDefault to use the current default allocator.

    maxLength

    The maximum number of Unicode characters that can be stored by the returned object. Pass 0 if there should be no character limit. Note that initially the returned object still has the same length as the string argument; this parameter simply specifies what the maximum size is. CFString might try to optimize its internal storage by paying attention to this value.

    theString

    A string to copy.

    Return Value

    A string that has the same contents as theString. Returns NULL if there was a problem copying the object. Ownership follows the Create Rule in Memory Management Programming Guide for Core Foundation.

    Discussion

    The returned mutable string is identical to the original string except for (perhaps) the mutability attribute. You can add character data to the returned string with any of the CFStringAppend... functions, and you can insert, delete, replace, pad, and trim characters with the appropriate CFString functions. If the maxLength parameter is greater than 0, any attempt to add characters beyond this limit results in a run-time error.

    Import Statement

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

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

    Declaration

    Swift

    func CFStringCreateMutableWithExternalCharactersNoCopy(_ alloc: CFAllocator!, _ chars: UnsafeMutablePointer<UniChar>, _ numChars: CFIndex, _ capacity: CFIndex, _ externalCharactersAllocator: CFAllocator!) -> CFMutableString!

    Objective-C

    CFMutableStringRef CFStringCreateMutableWithExternalCharactersNoCopy ( CFAllocatorRef alloc, UniChar *chars, CFIndex numChars, CFIndex capacity, CFAllocatorRef externalCharactersAllocator );

    Parameters

    alloc

    The allocator to use to allocate memory for the string. Pass NULL or kCFAllocatorDefault to use the current default allocator.

    chars

    The Unicode character buffer for the new CFMutableString. Before calling, create this buffer on the stack or heap and optionally initialize it with Unicode character data. Upon return, the created CFString object keeps its own copy of the pointer to this buffer. You may pass in NULL if there is no initial buffer being provided.

    numChars

    The number of characters initially in the Unicode buffer pointed to by chars.

    capacity

    The capacity of the external buffer (chars); that is, the maximum number of Unicode characters that can be stored. This value should be 0 if no initial buffer is provided.

    externalCharactersAllocator

    The allocator to use to reallocate the external buffer when editing takes place and for deallocating the buffer when string is deallocated. If the default allocator is suitable for these purposes, pass NULL. If you do not want the new string to reallocate or deallocate memory for the buffer (that is, you assume responsibility for these things yourself), pass kCFAllocatorNull.

    Return Value

    A new mutable string, or NULL if there was a problem creating the object. Ownership follows the Create Rule in Memory Management Programming Guide for Core Foundation.

    Discussion

    This function permits you to create a CFMutableString object whose backing store is an external Unicode character buffer—that is, a buffer that you control (or can control) entirely. This function allows you to take advantage of the features of CFString, particularly the CFMutableString functions that add and modify character data. But at the same time you can directly add, delete, modify, and examine the characters in the buffer. You can even replace the buffer entirely. If, however, you directly modify or replace the character buffer, you should inform the CFString object of this change with the CFStringSetExternalCharactersNoCopy function.

    If you mutate the character contents with the CFString functions, and the buffer needs to be enlarged, the CFString object calls the allocation callbacks specified for the allocator externalCharactersAllocator.

    This function should be used in special circumstances where you want to create a CFString wrapper around an existing, potentially large UniChar buffer you own. Using this function causes the CFString object to forgo some of its internal optimizations, so it should be avoided in general use. That is, if you want to create a CFString object from a small UniChar buffer, and you don't need to continue owning the buffer, use one of the other creation functions (for instance CFStringCreateWithCharacters) instead.

    Import Statement

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

  • Deletes a range of characters in a string.

    Declaration

    Swift

    func CFStringDelete(_ theString: CFMutableString!, _ range: CFRange)

    Objective-C

    void CFStringDelete ( CFMutableStringRef theString, CFRange range );

    Parameters

    theString

    A string from which characters are to be deleted.

    range

    The range of characters in theString to delete.

    Discussion

    The characters after the deleted range are adjusted to “fill in” the gap.

    Import Statement

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

  • Replaces all occurrences of a substring within a given range.

    Declaration

    Swift

    func CFStringFindAndReplace(_ theString: CFMutableString!, _ stringToFind: CFString!, _ replacementString: CFString!, _ rangeToSearch: CFRange, _ compareOptions: CFStringCompareFlags) -> CFIndex

    Objective-C

    CFIndex CFStringFindAndReplace ( CFMutableStringRef theString, CFStringRef stringToFind, CFStringRef replacementString, CFRange rangeToSearch, CFStringCompareFlags compareOptions );

    Parameters

    theString

    The string to modify.

    stringToFind

    The substring to search for in theString.

    replacementString

    The replacement string for stringToFind.

    rangeToSearch

    The range within which to search in theString.

    compareOptions

    Flags that select different types of comparisons, such as localized comparison, case-insensitive comparison, and non-literal comparison. If you want the default comparison behavior, pass 0. See CFStringCompareFlags for the available flags.

    Return Value

    The number of instances of stringToFind that were replaced.

    Discussion

    The possible values of compareOptions are combinations of the kCFCompareCaseInsensitive, kCFCompareBackwards, kCFCompareNonliteral, and kCFCompareAnchored constants.

    The kCFCompareBackwards option can be used to replace a substring starting from the end, which could produce different results. For example, if the parameter theString is “AAAAA”, stringToFind is “AA”, and replacementString is “B”, then the result is normally “BBA”. However, if the kCFCompareBackwards constant is used, the result is “ABB.”

    The kCFCompareAnchored option assures that only anchored but multiple instances are found (the instances must be consecutive at start or end). For example, if the parameter theString is “AAXAA”, stringToFind is “A”, and replacementString is “B”, then the result is normally “BBXBB.” However, if the kCFCompareAnchored constant is used, the result is “BBXAA.”

    Import Statement

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

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

    Declaration

    Swift

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

    Objective-C

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

    Import Statement

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

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

    Declaration

    Swift

    func CFStringInsert(_ str: CFMutableString!, _ index: CFIndex, _ insertedStr: CFString!)

    Objective-C

    void CFStringInsert ( CFMutableStringRef str, CFIndex idx, CFStringRef insertedStr );

    Parameters

    str

    The string to be modified. If this value is not a CFMutableString object, an assertion is raised.

    index

    The index of the character in str after which the new characters are to be inserted. If the index is out of bounds, an assertion is raised.

    insertedStr

    The string to insert into str.

    Discussion

    To accommodate the new characters, this function moves any existing characters to the right of the inserted characters the appropriate number of positions.

    Import Statement

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

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

    Declaration

    Swift

    func CFStringLowercase(_ theString: CFMutableString!, _ locale: CFLocale!)

    Objective-C

    void CFStringLowercase ( CFMutableStringRef theString, CFLocaleRef locale );

    Parameters

    theString

    The string to be lowercased. If this value is not a CFMutableString object, an assertion is raised.

    locale

    The locale to use when the lowercasing operation is performed. Prior to OS X v10.3 this parameter was an untyped pointer and not used.

    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.

    Special Considerations

    The locale parameter type changed from void * to CFLocaleRef in OS X v10.3.

    Import Statement

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

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

    Declaration

    Swift

    func CFStringNormalize(_ theString: CFMutableString!, _ theForm: CFStringNormalizationForm)

    Objective-C

    void CFStringNormalize ( CFMutableStringRef theString, CFStringNormalizationForm theForm );

    Parameters

    theString

    The string to be normalized.

    theForm

    The form to normalize theString.

    Import Statement

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

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

    Declaration

    Swift

    func CFStringPad(_ theString: CFMutableString!, _ padString: CFString!, _ length: CFIndex, _ indexIntoPad: CFIndex)

    Objective-C

    void CFStringPad ( CFMutableStringRef theString, CFStringRef padString, CFIndex length, CFIndex indexIntoPad );

    Parameters

    theString

    The string to modify.

    padString

    A string containing the characters with which to fill the extended character buffer. Pass NULL to truncate the string.

    length

    The new length of theString. If this length is greater than the current length, padding takes place; if it is less, truncation takes place.

    indexIntoPad

    The index of the character in padString with which to begin padding. If you are truncating the string represented by the object, this parameter is ignored.

    Discussion

    This function has two purposes. It either enlarges the character buffer of a CFMutableString object to a given length, padding the added length with a given character or characters, or it truncates the character buffer to a smaller size. The key parameter for this behavior is length; if it is greater than the current length of the represented string, padding takes place, and if it less than the current length, truncation occurs.

    For example, say you have a string, aMutStr, containing the characters "abcdef". The call

    • CFStringPad(aMutStr, CFSTR("123"), 9, 1);

    results in aMutStr containing "abcdef231". However, the following call

    • CFStringPad(aMutStr, NULL, 3, 0);

    results in aMutStr containing "abc".

    Import Statement

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

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

    Declaration

    Swift

    func CFStringReplace(_ theString: CFMutableString!, _ range: CFRange, _ replacement: CFString!)

    Objective-C

    void CFStringReplace ( CFMutableStringRef theString, CFRange range, CFStringRef replacement );

    Parameters

    theString

    The string to modify. The characters are adjusted left or right (depending on the length of the substituted string) and the character buffer of the object is resized accordingly. If this value is not a CFMutableString object, an assertion is raised.

    range

    The range of characters in theString to replace.

    replacement

    The replacement string to put into theString.

    Discussion

    Although you can use this function to replace all characters in a CFMutableString object (by specifying a range of (0, CFStringGetLength(theString)) ), it is more convenient to use the CFStringReplaceAll function for that purpose.

    Import Statement

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

  • Replaces all characters of a CFMutableString object with other characters.

    Declaration

    Swift

    func CFStringReplaceAll(_ theString: CFMutableString!, _ replacement: CFString!)

    Objective-C

    void CFStringReplaceAll ( CFMutableStringRef theString, CFStringRef replacement );

    Parameters

    theString

    The string to modify. If this value is not a CFMutableString object, an assertion is raised.

    replacement

    The replacement string to put into theString.

    Discussion

    The character buffer of theString is resized according to the length of the new characters.

    Import Statement

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

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

    Declaration

    Swift

    func CFStringSetExternalCharactersNoCopy(_ theString: CFMutableString!, _ chars: UnsafeMutablePointer<UniChar>, _ length: CFIndex, _ capacity: CFIndex)

    Objective-C

    void CFStringSetExternalCharactersNoCopy ( CFMutableStringRef theString, UniChar *chars, CFIndex length, CFIndex capacity );

    Parameters

    theString

    The string to act as a “wrapper” for the external backing store (chars). If this value is not a CFMutableString object, an assertion is raised.

    chars

    The external (client-owned) Unicode buffer acting as the backing store for theString.

    length

    The current length of the contents of chars (in Unicode characters).

    capacity

    The capacity of the Unicode buffer—that is, the total number of Unicode characters that can be stored in it before the buffer has to be grown.

    Discussion

    You use this function to reallocate memory for a string, if necessary, and change its references to the data in the buffer. The object must have been created with the CFStringCreateMutableWithExternalCharactersNoCopy function; see the discussion of this function for more information.

    Import Statement

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

  • Perform in-place transliteration on a mutable string.

    Declaration

    Swift

    func CFStringTransform(_ string: CFMutableString!, _ range: UnsafeMutablePointer<CFRange>, _ transform: CFString!, _ reverse: Boolean) -> Boolean

    Objective-C

    Boolean CFStringTransform ( CFMutableStringRef string, CFRange *range, CFStringRef transform, Boolean reverse );

    Parameters

    string

    The string to transform.

    range

    A pointer to the range over which the transformation is applied. NULL causes the whole string to be transformed. On return, range is modified to reflect the new range corresponding to the original range.

    transform

    A CFString object that identifies the transformation to apply. For a list of valid values, see Transform Identifiers for CFStringTransform. On OS X v10.4 and later, you can also use any valid ICU transform ID defined in the ICU User Guide for Transforms.

    reverse

    A Boolean that, if true, specifies that the inverse transform should be used (if it exists).

    Return Value

    true if the transform is successful; otherwise false.

    Discussion

    The transformation represented by transform is applied to the given range of string, modifying it in place. Only the specified range is modified, but the transform may look at portions of the string outside that range for context. Reasons that the transform may be unsuccessful include an invalid transform identifier, and attempting to reverse an irreversible transform.

    Import Statement

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

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

    Declaration

    Swift

    func CFStringTrim(_ theString: CFMutableString!, _ trimString: CFString!)

    Objective-C

    void CFStringTrim ( CFMutableStringRef theString, CFStringRef trimString );

    Parameters

    theString

    The string to trim. If this value is not a CFMutableString object, an assertion is raised.

    trimString

    The string to trim from theString. The characters of the trim string are treated as a substring and not individually; for example, if the mutable characters are "abc X" and the trim string is "XY", the mutable characters are not affected.

    Import Statement

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

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

    Declaration

    Swift

    func CFStringTrimWhitespace(_ theString: CFMutableString!)

    Objective-C

    void CFStringTrimWhitespace ( CFMutableStringRef theString );

    Parameters

    theString

    The string to trim. If this value is not a CFMutableString object, an assertion is raised.

    Discussion

    Whitespace for this function includes space characters, tabs, newlines, carriage returns, and any similar characters that do not have a visible representation.

    Import Statement

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

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

    Declaration

    Swift

    func CFStringUppercase(_ theString: CFMutableString!, _ locale: CFLocale!)

    Objective-C

    void CFStringUppercase ( CFMutableStringRef theString, CFLocaleRef locale );

    Parameters

    theString

    The string to uppercase. If this value is not a CFMutableString object, an assertion is raised.

    locale

    A CFLocale object that specifies a particular language or region. Prior to OS X v10.3, this parameter was an untyped pointer and not used.

    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.

    Import Statement

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

Data Types

Miscellaneous

  • A reference to a CFMutableString object.

    Declaration

    Swift

    typealias CFMutableStringRef = CFMutableString

    Objective-C

    typedef CFStringRef CFMutableStringRef;

    Discussion

    The type refers to a CFMutableString object, which “encapsulates” a Unicode string along with its length; the object has the attribute of being mutable, which means that its character contents can be modified. CFString is an opaque type that defines the characteristics and behavior of CFString objects, both immutable and mutable.

    CFMutableString derives from CFString. Therefore, you can pass CFMutableString objects into functions accepting CFString objects.

    Import Statement

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

Constants

Miscellaneous

  • Unicode normalization forms as described in Unicode Technical Report #15.

    Declaration

    Swift

    enum CFStringNormalizationForm : CFIndex { case D case KD case C case KC }

    Objective-C

    enum CFStringNormalizationForm { kCFStringNormalizationFormD = 0, kCFStringNormalizationFormKD = 1, kCFStringNormalizationFormC = 2, kCFStringNormalizationFormKC = 3 }; typedef enum CFStringNormalizationForm CFStringNormalizationForm;

    Constants

    • D

      kCFStringNormalizationFormD

      Canonical decomposition.

      Available in iOS 2.0 and later.

    • KD

      kCFStringNormalizationFormKD

      Compatibility decomposition.

      Available in iOS 2.0 and later.

    • C

      kCFStringNormalizationFormC

      Canonical decomposition followed by canonical composition.

      Available in iOS 2.0 and later.

    • KC

      kCFStringNormalizationFormKC

      Compatibility decomposition followed by canonical composition.

      Available in iOS 2.0 and later.

    Import Statement

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later.

  • Constants that identify transforms used with CFStringTransform.

    Declaration

    Swift

    let kCFStringTransformStripCombiningMarks: CFString! let kCFStringTransformToLatin: CFString! let kCFStringTransformFullwidthHalfwidth: CFString! let kCFStringTransformLatinKatakana: CFString! let kCFStringTransformLatinHiragana: CFString! let kCFStringTransformHiraganaKatakana: CFString! let kCFStringTransformMandarinLatin: CFString! let kCFStringTransformLatinHangul: CFString! let kCFStringTransformLatinArabic: CFString! let kCFStringTransformLatinHebrew: CFString! let kCFStringTransformLatinThai: CFString! let kCFStringTransformLatinCyrillic: CFString! let kCFStringTransformLatinGreek: CFString! let kCFStringTransformToXMLHex: CFString! let kCFStringTransformToUnicodeName: CFString! let kCFStringTransformStripDiacritics: CFString!

    Objective-C

    const CFStringRef kCFStringTransformStripCombiningMarks; const CFStringRef kCFStringTransformToLatin; const CFStringRef kCFStringTransformFullwidthHalfwidth; const CFStringRef kCFStringTransformLatinKatakana; const CFStringRef kCFStringTransformLatinHiragana; const CFStringRef kCFStringTransformHiraganaKatakana; const CFStringRef kCFStringTransformMandarinLatin; const CFStringRef kCFStringTransformLatinHangul; const CFStringRef kCFStringTransformLatinArabic; const CFStringRef kCFStringTransformLatinHebrew; const CFStringRef kCFStringTransformLatinThai; const CFStringRef kCFStringTransformLatinCyrillic; const CFStringRef kCFStringTransformLatinGreek; const CFStringRef kCFStringTransformToXMLHex; const CFStringRef kCFStringTransformToUnicodeName; const CFStringRef kCFStringTransformStripDiacritics;

    Constants

    • kCFStringTransformStripCombiningMarks

      kCFStringTransformStripCombiningMarks

      The identifier of a transform to strip combining marks (accents or diacritics).

      Available in iOS 2.0 and later.

    • kCFStringTransformToLatin

      kCFStringTransformToLatin

      The identifier of a transform to transliterate all text possible to Latin script. Ideographs are transliterated as Mandarin Chinese.

      Available in iOS 2.0 and later.

    • kCFStringTransformFullwidthHalfwidth

      kCFStringTransformFullwidthHalfwidth

      The identifier of a reversible transform to convert full-width characters to their half-width equivalents.

      Available in iOS 2.0 and later.

    • kCFStringTransformLatinKatakana

      kCFStringTransformLatinKatakana

      The identifier of a reversible transform to transliterate text to Katakana from Latin.

      Available in iOS 2.0 and later.

    • kCFStringTransformLatinHiragana

      kCFStringTransformLatinHiragana

      The identifier of a reversible transform to transliterate text to Hiragana from Latin.

      Available in iOS 2.0 and later.

    • kCFStringTransformHiraganaKatakana

      kCFStringTransformHiraganaKatakana

      The identifier of a reversible transform to transliterate text to Katakana from Hiragana.

      Available in iOS 2.0 and later.

    • kCFStringTransformMandarinLatin

      kCFStringTransformMandarinLatin

      The identifier of a transform to transliterate text to Latin from ideographs interpreted as Mandarin Chinese. This transform is not reversible.

      Available in iOS 2.0 and later.

    • kCFStringTransformLatinHangul

      kCFStringTransformLatinHangul

      The identifier of a reversible transform to transliterate text to Hangul from Latin.

      Available in iOS 2.0 and later.

    • kCFStringTransformLatinArabic

      kCFStringTransformLatinArabic

      The identifier of a reversible transform to transliterate text to Arabic from Latin.

      Available in iOS 2.0 and later.

    • kCFStringTransformLatinHebrew

      kCFStringTransformLatinHebrew

      The identifier of a reversible transform to transliterate text to Hebrew from Latin.

      Available in iOS 2.0 and later.

    • kCFStringTransformLatinThai

      kCFStringTransformLatinThai

      The identifier of a reversible transform to transliterate text to Thai from Latin.

      Available in iOS 2.0 and later.

    • kCFStringTransformLatinCyrillic

      kCFStringTransformLatinCyrillic

      The identifier of a reversible transform to transliterate text to Cyrillic from Latin.

      Available in iOS 2.0 and later.

    • kCFStringTransformLatinGreek

      kCFStringTransformLatinGreek

      The identifier of a reversible transform to transliterate text to Greek from Latin.

      Available in iOS 2.0 and later.

    • kCFStringTransformToXMLHex

      kCFStringTransformToXMLHex

      The identifier of a reversible transform to transliterate characters other than printable ASCII to XML/HTML numeric entities.

      Available in iOS 2.0 and later.

    • kCFStringTransformToUnicodeName

      kCFStringTransformToUnicodeName

      The identifier of a reversible transform to transliterate characters other than printable ASCII (minus braces) to their Unicode character name in braces.

      Examples include {AIRPLANE} and {GREEK CAPITAL LETTER PSI}.

      Available in iOS 2.0 and later.

    • kCFStringTransformStripDiacritics

      kCFStringTransformStripDiacritics

      The identifier of a transform to remove diacritic markings.

      Available in iOS 2.0 and later.

    Discussion

    On OS X v10.4 and later, with CFStringTransform you can also use any valid ICU transform ID defined in the ICU User Guide for Transforms.

    Import Statement