// encoding/utf8 — UTF-8 helpers. RFC 3629; we only handle the legal // subset (no over-long encodings, no surrogates). def MAX: rune = 1114111; // 0x10FFFF // runesz — encoded byte length of `r` as UTF-8. void variant means // `r` is outside the legal range (negative, > 0x10FFFF). export fn runesz(r: rune) (i32 | void) = { if (r < 0) { return; }; if (r < 128) { return 1; }; if (r < 2048) { return 2; }; if (r < 65536) { return 3; }; if (r <= MAX) { return 4; }; return; };