= Surrogate pair
A <surrogate pair> is the two-<code unit> representation used by <UTF-16> for a <Unicode scalar value> above `U+FFFF`. The high surrogate lies in `D800`–`DBFF` and the low surrogate in `DC00`–`DFFF`, written in <hexadecimal>. They encode one value together; neither surrogate alone is a <Unicode scalar value>.<The Unicode Standard Version 17 Core Specification>[§3.9.2, UTF-16 and surrogate-pair mapping]{ref}
For numerical units $H,L$, the decoded value is
$$
U=\mathtt{10000}_{16}+2^{10}(H-\mathtt{D800}_{16})+(L-\mathtt{DC00}_{16}).
$$
Thus `D83D DE00` gives `U+1F600`. Swapping the units or discarding one half breaks that encoding. A <string> operation specified in <code units> must therefore account for pairs when it intends to preserve complete <code points>; a <grapheme cluster> can require still more units.
Back to article page