pub fn utf8CodepointSequenceLength(c: u21) !u3 c: u2117
18
19
20
21
22
23pub fn utf8CodepointSequenceLength(c: u21) !u3 {
if (c < 0x80) return @as(u3, 1);
if (c < 0x800) return @as(u3, 2);
if (c < 0x10000) return @as(u3, 3);
if (c < 0x110000) return @as(u3, 4);
return error.CodepointTooLarge;
}
Returns how many bytes the UTF-8 representation would require for the given codepoint.