Contents

CFStringGetCharacterAtIndex(_:_:)

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

Declaration

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

A Unicode character.

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