iOS Developer Library

Developer

CoreFoundation Framework Reference CFCharacterSet Reference

Options
Deployment Target:

On This Page
Language:

CFCharacterSet Reference

Inherits From


Not Applicable

Conforms To


Not Applicable

Import Statement


Swift

import CoreFoundation

Objective-C

@import CoreFoundation;

A CFCharacterSet object represents a set of Unicode compliant characters. CFString uses CFCharacterSet objects to group characters together for searching operations, so that they can find any of a particular set of characters during a search. The two opaque types, CFCharacterSet and CFMutableCharacterSet Reference, define the interface for static and dynamic character sets, respectively. The objects you create using these opaque types are referred to as character set objects (and when no confusion will result, merely as character sets).

CFCharacterSet's principal function, CFCharacterSetIsCharacterMember, provides the basis for all other functions in its interface. You create a character set using one of the CFCharacterSetCreate... functions. You may also use any one of the predefined character sets using the CFCharacterSetGetPredefined function.

CFCharacterSet is “toll-free bridged” with its Cocoa Foundation counterpart, NSCharacterSet. 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 NSCharacterSet * parameter, you can pass in a CFCharacterSetRef, and in a function where you see a CFCharacterSetRef parameter, you can pass in an NSCharacterSet instance. This capability also applies to concrete subclasses of NSCharacterSet. See Toll-Free Bridged Types for more information on toll-free bridging.

Functions

  • Creates a new character set with the values from a given character set.

    Declaration

    Swift

    func CFCharacterSetCreateCopy(_ alloc: CFAllocator!, _ theSet: CFCharacterSet!) -> CFCharacterSet!

    Objective-C

    CFCharacterSetRef CFCharacterSetCreateCopy ( CFAllocatorRef alloc, CFCharacterSetRef theSet );

    Parameters

    alloc

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

    theSet

    The character set to copy.

    Return Value

    A new character set that is a copy of theSet. Ownership follows the Create Rule.

    Discussion

    This function tries to compact the backing store where applicable.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later

  • Creates a new immutable character set that is the invert of the specified character set.

    Declaration

    Swift

    func CFCharacterSetCreateInvertedSet(_ alloc: CFAllocator!, _ theSet: CFCharacterSet!) -> CFCharacterSet!

    Objective-C

    CFCharacterSetRef CFCharacterSetCreateInvertedSet ( CFAllocatorRef alloc, CFCharacterSetRef theSet );

    Parameters

    alloc

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

    theSet

    The character set from which to create an inverted set.

    Return Value

    A new character set that is the invert of theSet. Ownership follows the Create Rule.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later

  • Creates a new character set with the values from the given range of Unicode characters.

    Declaration

    Swift

    func CFCharacterSetCreateWithCharactersInRange(_ alloc: CFAllocator!, _ theRange: CFRange) -> CFCharacterSet!

    Objective-C

    CFCharacterSetRef CFCharacterSetCreateWithCharactersInRange ( CFAllocatorRef alloc, CFRange theRange );

    Parameters

    alloc

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

    theRange

    The Unicode range of characters of the new character set. The function accepts the range in 32-bit in the UTF-32 format. The valid character point range is from 0x00000 to 0x10FFFF.

    Return Value

    A new character set that contains a contiguous range of Unicode characters. Ownership follows the Create Rule.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later

  • Creates a new character set with the values in the given string.

    Declaration

    Swift

    func CFCharacterSetCreateWithCharactersInString(_ alloc: CFAllocator!, _ theString: CFString!) -> CFCharacterSet!

    Objective-C

    CFCharacterSetRef CFCharacterSetCreateWithCharactersInString ( CFAllocatorRef alloc, CFStringRef theString );

    Parameters

    alloc

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

    theString

    A string containing the characters for the new set.

    Return Value

    A new character set containing the characters from theString. Ownership follows the Create Rule.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later

  • Creates a new immutable character set with the bitmap representation specified by given data.

    Declaration

    Swift

    func CFCharacterSetCreateWithBitmapRepresentation(_ alloc: CFAllocator!, _ theData: CFData!) -> CFCharacterSet!

    Objective-C

    CFCharacterSetRef CFCharacterSetCreateWithBitmapRepresentation ( CFAllocatorRef alloc, CFDataRef theData );

    Parameters

    alloc

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

    theData

    A CFData object that specifies the bitmap representation of the Unicode character points the for the new character set. The bitmap representation could contain all the Unicode character range starting from BMP to Plane 16. The first 8KiB (8192 bytes) of the data represent the BMP range. The BMP range 8KiB can be followed by zero to sixteen 8KiB bitmaps, each prepended with the plane index byte. For example, the bitmap representing the BMP and Plane 2 has the size of 16385 bytes (8KiB for BMP, 1 byte index, and a 8KiB bitmap for Plane 2). The plane index byte, in this case, contains the integer value two.

    If the data contains a Plane index byte outside of the valid Plane range (1 to 16), the behavior is undefined.

    Return Value

    A new character set containing the indicated characters from theData. Ownership follows the Create Rule.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later

  • Creates a new immutable data with the bitmap representation from the given character set.

    Declaration

    Swift

    func CFCharacterSetCreateBitmapRepresentation(_ alloc: CFAllocator!, _ theSet: CFCharacterSet!) -> CFData!

    Objective-C

    CFDataRef CFCharacterSetCreateBitmapRepresentation ( CFAllocatorRef alloc, CFCharacterSetRef theSet );

    Parameters

    alloc

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

    theSet

    The set from which to create a bitmap representation. Refer to the comments for CFCharacterSetCreateWithBitmapRepresentation for the detailed discussion of the bitmap representation format.

    Return Value

    A new CFData object containing a bitmap representation of theSet. Ownership follows the Create Rule.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later

  • Reports whether or not a character set contains at least one member character in the specified plane.

    Declaration

    Swift

    func CFCharacterSetHasMemberInPlane(_ theSet: CFCharacterSet!, _ thePlane: CFIndex) -> Boolean

    Objective-C

    Boolean CFCharacterSetHasMemberInPlane ( CFCharacterSetRef theSet, CFIndex thePlane );

    Parameters

    theSet

    The character set to examine.

    thePlane

    The plane number to be checked for the membership. The valid value range is from 0 to 16. If the value is outside of the valid plane number range, the behavior is undefined.

    Return Value

    true if at least one member character is in the specified plane, otherwise false.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later

  • Reports whether or not a given Unicode character is in a character set.

    Declaration

    Swift

    func CFCharacterSetIsCharacterMember(_ theSet: CFCharacterSet!, _ theChar: UniChar) -> Boolean

    Objective-C

    Boolean CFCharacterSetIsCharacterMember ( CFCharacterSetRef theSet, UniChar theChar );

    Parameters

    theSet

    The character set to examine.

    theChar

    The Unicode character for which to test against the character set. Note that this function takes 16-bit Unicode character value; hence, it does not support access to the non-BMP planes.

    Return Value

    true if theSet contains theChar, otherwise false.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later

  • Reports whether or not a given UTF-32 character is in a character set.

    Declaration

    Swift

    func CFCharacterSetIsLongCharacterMember(_ theSet: CFCharacterSet!, _ theChar: UTF32Char) -> Boolean

    Objective-C

    Boolean CFCharacterSetIsLongCharacterMember ( CFCharacterSetRef theSet, UTF32Char theChar );

    Parameters

    theSet

    The character set to examine.

    theChar

    The UTF-32 character for which to test against the character set.

    Return Value

    true if theSet contains theChar, otherwise false.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later

  • Reports whether or not a character set is a superset of another set.

    Declaration

    Swift

    func CFCharacterSetIsSupersetOfSet(_ theSet: CFCharacterSet!, _ theOtherSet: CFCharacterSet!) -> Boolean

    Objective-C

    Boolean CFCharacterSetIsSupersetOfSet ( CFCharacterSetRef theSet, CFCharacterSetRef theOtherset );

    Parameters

    theSet

    The character set to be checked for the membership of theOtherSet.

    theOtherSet

    The character set to be checked whether or not it is a subset of theSet.

    Return Value

    true if theSet is a superset of theOtherSet, otherwise false.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later

  • Returns the type identifier of the CFCharacterSet opaque type.

    Declaration

    Swift

    func CFCharacterSetGetTypeID() -> CFTypeID

    Objective-C

    CFTypeID CFCharacterSetGetTypeID ( void );

    Return Value

    The type identifier of the CFCharacterSet opaque type.

    Discussion

    CFMutableCharacterSet objects have the same type identifier as CFCharacterSet objects.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later

Data Types

Miscellaneous

  • Defines a predefined character set.

    Declaration

    Swift

    enum CFCharacterSetPredefinedSet : CFIndex { case Control case Whitespace case WhitespaceAndNewline case DecimalDigit case Letter case LowercaseLetter case UppercaseLetter case NonBase case Decomposable case AlphaNumeric case Punctuation case CapitalizedLetter case Symbol case Newline case Illegal }

    Objective-C

    typedef CFIndex CFCharacterSetPredefinedSet;

    Discussion

    See Predefined CFCharacterSet Selector Values for values.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later

  • A reference to an immutable character set object.

    Declaration

    Swift

    typealias CFCharacterSetRef = CFCharacterSet

    Objective-C

    typedef const struct __CFCharacterSet *CFCharacterSetRef;

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in iOS 2.0 and later

Constants

Miscellaneous

  • Identifiers for the available predefined CFCharacterSet objects.

    Declaration

    Swift

    case Control case Whitespace case WhitespaceAndNewline case DecimalDigit case Letter case LowercaseLetter case UppercaseLetter case NonBase case Decomposable case AlphaNumeric case Punctuation case CapitalizedLetter case Symbol case Newline case Illegal

    Objective-C

    enum { kCFCharacterSetControl = 1, kCFCharacterSetWhitespace, kCFCharacterSetWhitespaceAndNewline, kCFCharacterSetDecimalDigit, kCFCharacterSetLetter, kCFCharacterSetLowercaseLetter, kCFCharacterSetUppercaseLetter, kCFCharacterSetNonBase, kCFCharacterSetDecomposable, kCFCharacterSetAlphaNumeric, kCFCharacterSetPunctuation, kCFCharacterSetCapitalizedLetter = 13, kCFCharacterSetSymbol = 14, kCFCharacterSetNewline = 15, kCFCharacterSetIllegal = 12 };

    Constants

    • Control

      kCFCharacterSetControl

      Control character set (Unicode General Category Cc and Cf).

      Available in iOS 2.0 and later

    • Whitespace

      kCFCharacterSetWhitespace

      Whitespace character set (Unicode General Category Zs and U0009 CHARACTER TABULATION).

      Available in iOS 2.0 and later

    • WhitespaceAndNewline

      kCFCharacterSetWhitespaceAndNewline

      Whitespace and Newline character set (Unicode General Category Z*, U000A ~ U000D, and U0085).

      Available in iOS 2.0 and later

    • DecimalDigit

      kCFCharacterSetDecimalDigit

      Decimal digit character set.

      Available in iOS 2.0 and later

    • Letter

      kCFCharacterSetLetter

      Letter character set (Unicode General Category L* & M*).

      Available in iOS 2.0 and later

    • LowercaseLetter

      kCFCharacterSetLowercaseLetter

      Lowercase character set (Unicode General Category Ll).

      Available in iOS 2.0 and later

    • UppercaseLetter

      kCFCharacterSetUppercaseLetter

      Uppercase character set (Unicode General Category Lu and Lt).

      Available in iOS 2.0 and later

    • NonBase

      kCFCharacterSetNonBase

      Non-base character set (Unicode General Category M*).

      Available in iOS 2.0 and later

    • Decomposable

      kCFCharacterSetDecomposable

      Canonically decomposable character set.

      Available in iOS 2.0 and later

    • AlphaNumeric

      kCFCharacterSetAlphaNumeric

      Alpha Numeric character set (Unicode General Category L*, M*, & N*).

      Available in iOS 2.0 and later

    • Punctuation

      kCFCharacterSetPunctuation

      Punctuation character set (Unicode General Category P*).

      Available in iOS 2.0 and later

    • CapitalizedLetter

      kCFCharacterSetCapitalizedLetter

      Titlecase character set (Unicode General Category Lt).

      Available in iOS 2.0 and later

    • Symbol

      kCFCharacterSetSymbol

      Symbol character set (Unicode General Category S*).

      Available in iOS 2.0 and later

    • Newline

      kCFCharacterSetNewline

      Newline character set (U000A ~ U000D, U0085, U2028, and U2029).

      Available in iOS 2.0 and later

    • Illegal

      kCFCharacterSetIllegal

      Illegal character set.

      Available in iOS 2.0 and later

    Discussion

    Use these constants with the CFCharacterSetGetPredefined function to get one of the predefined character sets.