klyn.String.codeUnits
property
public readonly property codeUnits as CodeUnit[]:
Description

Returns a snapshot of this string encoded as UTF-16 code units.

CodeUnit is a 16-bit UTF-16 code unit. Consequently, one supplementary Unicode scalar is represented by two adjacent values in this array.

Returns

A newly allocated UTF-16 snapshot.

Example
units = "A😀B".codeUnits
assert units.size == 4
assert units[1] == `\uD83D`
assert units[2] == `\uDE00`