---
title: "CFStringGetCharacters(_:_:_:)"
framework: corefoundation
role: symbol
role_heading: Function
path: "corefoundation/cfstringgetcharacters(_:_:_:)"
---

# CFStringGetCharacters(_:_:_:)

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

## Declaration

```swift
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

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(_:_:_:) and CFStringGetCharacterFromInlineBuffer(_:_:) to extract the characters incrementally.

## See Also

### Accessing Characters

- [CFStringCreateExternalRepresentation(_:_:_:_:)](corefoundation/cfstringcreateexternalrepresentation(_:_:_:_:).md)
- [CFStringGetBytes(_:_:_:_:_:_:_:_:)](corefoundation/cfstringgetbytes(_:_:_:_:_:_:_:_:).md)
- [CFStringGetCharacterAtIndex(_:_:)](corefoundation/cfstringgetcharacteratindex(_:_:).md)
- [CFStringGetCharactersPtr(_:)](corefoundation/cfstringgetcharactersptr(_:).md)
- [CFStringGetCharacterFromInlineBuffer(_:_:)](corefoundation/cfstringgetcharacterfrominlinebuffer(_:_:).md)
- [CFStringGetCString(_:_:_:_:)](corefoundation/cfstringgetcstring(_:_:_:_:).md)
- [CFStringGetCStringPtr(_:_:)](corefoundation/cfstringgetcstringptr(_:_:).md)
- [CFStringGetLength(_:)](corefoundation/cfstringgetlength(_:).md)
- [CFStringGetPascalString(_:_:_:_:)](corefoundation/cfstringgetpascalstring(_:_:_:_:).md)
- [CFStringGetPascalStringPtr(_:_:)](corefoundation/cfstringgetpascalstringptr(_:_:).md)
- [CFStringGetRangeOfComposedCharactersAtIndex(_:_:)](corefoundation/cfstringgetrangeofcomposedcharactersatindex(_:_:).md)
- [CFStringInitInlineBuffer(_:_:_:)](corefoundation/cfstringinitinlinebuffer(_:_:_:).md)
