Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Public Function

utf16DecodeSurrogatePair

Public Function
std.unicode.utf16DecodeSurrogatePair
pub fn utf16DecodeSurrogatePair(surrogate_pair: []const u16) !u21

Decodes the codepoint encoded in the given pair of UTF-16 code units. Asserts that surrogate_pair.len >= 2 and that the first code unit is a high surrogate. If the second code unit is not a low surrogate, error.ExpectedSecondSurrogateHalf is returned.

Params

  • surrogate_pair: []const u16

File

unicode.zig:482
482
483
484
485
486
487
488
489
pub 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);
}