---
title: "CFStringGetCharacterAtIndex(_:_:)"
framework: corefoundation
role: symbol
role_heading: Function
path: "corefoundation/cfstringgetcharacteratindex(_:_:)"
---

# CFStringGetCharacterAtIndex(_:_:)

Returns the Unicode character at a specified location in a string.

## Declaration

```swift
func CFStringGetCharacterAtIndex(_ theString: CFString!, _ idx: CFIndex) -> UniChar
```

## Parameters

- `theString`: The string from which the Unicode character is obtained.
- `idx`: The position of the Unicode character in the CFString.

## Return Value

Return Value A Unicode character.

## Discussion

Discussion This function is typically called in a loop to fetch the Unicode characters of a string in sequence or to fetch a character at a known position (first or last, for example). Using it in a loop can be inefficient, especially with longer strings, so consider the CFStringGetCharacters(_:_:_:) function or the in-line buffer functions (CFStringInitInlineBuffer(_:_:_:) and CFStringGetCharacterFromInlineBuffer(_:_:)) as alternatives.

## See Also

### Accessing Characters

- [CFStringCreateExternalRepresentation(_:_:_:_:)](corefoundation/cfstringcreateexternalrepresentation(_:_:_:_:).md)
- [CFStringGetBytes(_:_:_:_:_:_:_:_:)](corefoundation/cfstringgetbytes(_:_:_:_:_:_:_:_:).md)
- [CFStringGetCharacters(_:_:_:)](corefoundation/cfstringgetcharacters(_:_:_:).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)
