Function utf8Decode2 [src]
Prototype
pub fn utf8Decode2(bytes: [2]u8) Utf8Decode2Error!u21
Parameters
bytes: [2]u8
Possible Errors
Source
pub fn utf8Decode2(bytes: [2]u8) Utf8Decode2Error!u21 {
assert(bytes[0] & 0b11100000 == 0b11000000);
var value: u21 = bytes[0] & 0b00011111;
if (bytes[1] & 0b11000000 != 0b10000000) return error.Utf8ExpectedContinuation;
value <<= 6;
value |= bytes[1] & 0b00111111;
if (value < 0x80) return error.Utf8OverlongEncoding;
return value;
}