def utf8_bytes
import cli@0.2.0.0/cli.bend as Cliimport Base
7997# Scalar x's UTF-8, for x from 80: 2 bytes below 800, 3 below 10000, else 4.
7998def utf8_bytes(two: Bool, three: Bool, +x: U32) -> List<&2, U32>:
7999 match two three:
8000 case True{} _: [(192 + x / 64 : U32), cont_byte(x)]
8001 case False{} True{}:
8002 [(224 + x / 4096 : U32), cont_byte((x / 64 : U32)), cont_byte(x)]
8003 case False{} False{}:
8004 [(240 + x / 262144 : U32), cont_byte((x / 4096 : U32)),
8005 cont_byte((x / 64 : U32)), cont_byte(x)]