Surrogate Pairs
In UTF-16, most Unicode characters can be represented with a single 16-bit code unit. Only characters in the range 0x10000 to 0x10FFFF must be represented with a
surrogate pair of two UTF-16 code units.
RWUCharTraits provides the static method
RWUCharTraits::requiresSurrogatePair(), which returns
true if a given
RWUChar32 code point requires a surrogate representation.
Similarly,
RWUCharTraits::isHighSurrogate() returns
true if a given
RWUChar16 code unit is the first, or high, code unit of a surrogate pair. A high surrogate has a value in the range
U+D800 to
U+DBFF. The function
RWUCharTraits::isLowSurrogate() returns
true if a given
RWUChar16 code unit is the second, or low, code unit of a surrogate pair. A low surrogate has a value in the range
U+DC00 to
U+DFFF. The method
RWUCharTraits::isSurrogate() returns
true if a given
RWUChar16 is a surrogate in the range
U+D800 to
U+DFFF. Surrogates are not characters themselves; they are reserved for use as the low or high code unit in a surrogate pair.
Finally,
RWUCharTraits::isSingle() returns
true if a given
RWUChar16 code unit corresponds to a single code point, or
false if the value is part of a surrogate pair.