pub fn utf16DecodeSurrogatePair(surrogate_pair: []const u16) !u21 surrogate_pair: []const u16482
483
484
485
486
487
488
489pub fn utf16DecodeSurrogatePair(surrogate_pair: []const u16) !u21 {
assert(surrogate_pair.len >= 2);
assert(utf16IsHighSurrogate(surrogate_pair[0]));
const high_half: u21 = surrogate_pair[0];
const low_half = surrogate_pair[1];
if (!utf16IsLowSurrogate(low_half)) return error.ExpectedSecondSurrogateHalf;
return 0x10000 + ((high_half & 0x03ff) << 10) | (low_half & 0x03ff);
}
Decodes the codepoint encoded in the given pair of UTF-16 code units. Asserts that
surrogate_pair.len >= 2and that the first code unit is a high surrogate. If the second code unit is not a low surrogate, error.ExpectedSecondSurrogateHalf is returned.