Returns the number of code units required to encode the given Unicode scalar.
- Xcode 9.0+
- Swift Standard Library
A Unicode scalar value.
The width of
x when encoded in UTF-16, either
Because a Unicode scalar value can require up to 21 bits to store its value, some Unicode scalars are represented in UTF-16 by a pair of 16-bit code units. The first and second code units of the pair, designated leading and trailing surrogates, make up a surrogate pair.