Instance Method

character(at:)

Returns the character at a given UTF-16 code unit index.

Declaration

func character(at index: Int) -> unichar

Parameters

index

The index of the character to retrieve.

Return Value

The character at the array position given by index.

Discussion

You should always use the rangeOfComposedCharacterSequence(at:) or rangeOfComposedCharacterSequences(for:) method to determine character boundaries, so that any surrogate pairs or character clusters are handled correctly.