Zig 0.17.0-dev (Split by item)
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 library itself.
Zig › std/ › unicode.zig › utf8Decode4
utf8Decode4
unicode.utf8Decode4
pub fn utf8Decode4 (bytes : [4 ]u8 ) Utf8Decode4Error !u21
File
Code
pub fn utf8Decode4 (bytes : [4 ]u8 ) Utf8Decode4Error !u21 {
assert (bytes [0 ] & 0b11111000 == 0b11110000 );
var value : u21 = bytes [0 ] & 0b00000111 ;
if (bytes [1 ] & 0b11000000 != 0b10000000 ) return error .Utf8ExpectedContinuation ;
value <<= 6 ;
value |= bytes [1 ] & 0b00111111 ;
if (bytes [2 ] & 0b11000000 != 0b10000000 ) return error .Utf8ExpectedContinuation ;
value <<= 6 ;
value |= bytes [2 ] & 0b00111111 ;
if (bytes [3 ] & 0b11000000 != 0b10000000 ) return error .Utf8ExpectedContinuation ;
value <<= 6 ;
value |= bytes [3 ] & 0b00111111 ;
if (value < 0x10000 ) return error .Utf8OverlongEncoding ;
if (value > 0x10FFFF ) return error .Utf8CodepointTooLarge ;
return value ;
}