std.utf.byte_count

std.utf

byte_count(b1) -> count

Return the number of continuation bytes for a multi-byte UTF-8 character

Given the leading byte of a multi-byte UTF-8 sequence, returns the number of continuation bytes that follow it: 1 for a 2-byte sequence (0xC0–0xDF), 2 for a 3-byte sequence (0xE0–0xEF), or 3 for a 4-byte sequence (0xF0–0xF7). Behaviour is undefined for ASCII or continuation bytes — call valid_b1 first.