<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreFoundation",
  "identifier" : "/documentation/CoreFoundation/CFCharacterSet",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core Foundation"
    ],
    "preciseIdentifier" : "c:@T@CFCharacterSetRef"
  },
  "title" : "CFCharacterSet"
}
-->

# CFCharacterSet

```
class CFCharacterSet
```

## Overview

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`](/documentation/CoreFoundation/CFMutableCharacterSet), 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(_:_:)`](/documentation/CoreFoundation/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(_:)`](/documentation/CoreFoundation/CFCharacterSetGetPredefined(_:)) function.

CFCharacterSet is “toll-free bridged” with its Cocoa Foundation counterpart, <doc://com.apple.documentation/documentation/Foundation/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](https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFDesignConcepts/Articles/tollFreeBridgedTypes.html#//apple_ref/doc/uid/TP40010677) for more information on toll-free bridging.

## Topics

### Creating Character Sets

[`CFCharacterSetCreateCopy(_:_:)`](/documentation/CoreFoundation/CFCharacterSetCreateCopy(_:_:))

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

[`CFCharacterSetCreateInvertedSet(_:_:)`](/documentation/CoreFoundation/CFCharacterSetCreateInvertedSet(_:_:))

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

[`CFCharacterSetCreateWithCharactersInRange(_:_:)`](/documentation/CoreFoundation/CFCharacterSetCreateWithCharactersInRange(_:_:))

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

[`CFCharacterSetCreateWithCharactersInString(_:_:)`](/documentation/CoreFoundation/CFCharacterSetCreateWithCharactersInString(_:_:))

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

[`CFCharacterSetCreateWithBitmapRepresentation(_:_:)`](/documentation/CoreFoundation/CFCharacterSetCreateWithBitmapRepresentation(_:_:))

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

### Getting Predefined Character Sets

[`CFCharacterSetGetPredefined(_:)`](/documentation/CoreFoundation/CFCharacterSetGetPredefined(_:))

Returns a predefined character set.

### Querying Character Sets

[`CFCharacterSetCreateBitmapRepresentation(_:_:)`](/documentation/CoreFoundation/CFCharacterSetCreateBitmapRepresentation(_:_:))

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

[`CFCharacterSetHasMemberInPlane(_:_:)`](/documentation/CoreFoundation/CFCharacterSetHasMemberInPlane(_:_:))

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

[`CFCharacterSetIsCharacterMember(_:_:)`](/documentation/CoreFoundation/CFCharacterSetIsCharacterMember(_:_:))

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

[`CFCharacterSetIsLongCharacterMember(_:_:)`](/documentation/CoreFoundation/CFCharacterSetIsLongCharacterMember(_:_:))

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

[`CFCharacterSetIsSupersetOfSet(_:_:)`](/documentation/CoreFoundation/CFCharacterSetIsSupersetOfSet(_:_:))

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

### Getting the Character Set Type Identifier

[`CFCharacterSetGetTypeID()`](/documentation/CoreFoundation/CFCharacterSetGetTypeID())

Returns the type identifier of the CFCharacterSet opaque type.

### Data Types

[`CFCharacterSetPredefinedSet`](/documentation/CoreFoundation/CFCharacterSetPredefinedSet)

Defines a predefined character set.

### Constants

[Predefined CFCharacterSet Selector Values](/documentation/CoreFoundation/predefined_cfcharacterset_selector_values)

Identifiers for the available predefined CFCharacterSet objects.

## See Also

  [String Programming Guide for Core Foundation](https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFStrings/introCFStrings.html#//apple_ref/doc/uid/10000131i)



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)