<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreFoundation",
  "identifier" : "/documentation/CoreFoundation/CFStringGetCharacters(_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Foundation"
    ],
    "preciseIdentifier" : "c:@F@CFStringGetCharacters"
  },
  "title" : "CFStringGetCharacters(_:_:_:)"
}
-->

# CFStringGetCharacters(_:_:_:)

Copies a range of the Unicode characters from a string to a user-provided buffer.

```
func CFStringGetCharacters(_ theString: CFString!, _ range: CFRange, _ buffer: UnsafeMutablePointer<UniChar>!)
```

## Parameters

`theString`

The string from which the characters are to be obtained.

`range`

The range of characters to copy. The specified range must not exceed the length of the string.

`buffer`

The `UniChar` buffer of length `range.length` that you have allocated on the stack or heap. On return, the buffer contains the requested Unicode characters.

## Discussion

Use this function to obtain some or all of the Unicode characters represented by a CFString object. If this operation involves a large number of characters, the function call can be expensive in terms of memory. Instead you might want to consider using the in-line buffer functions [`CFStringInitInlineBuffer(_:_:_:)`](/documentation/CoreFoundation/CFStringInitInlineBuffer(_:_:_:)) and [`CFStringGetCharacterFromInlineBuffer(_:_:)`](/documentation/CoreFoundation/CFStringGetCharacterFromInlineBuffer(_:_:)) to extract the characters incrementally.

---

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)