def char_bytes
import cli@0.2.0.0/cli.bend as Cliimport Base
8016# The bytes c stands for: an escape's byte for U+DC80..U+DCFF, a Unicode
8017# scalar's UTF-8, and U+FFFD's for any other surrogate or a value past
8018# U+10FFFF, as Bend's writer prints them.
8019def char_bytes(c: Char) -> List<&2, U32>:
8020 match c:
8021 case Chr{+x}:
8022 code_bytes(U32.is_lt(x, 128), U32.is_lt((x - 56448 : U32), 128),
8023 Bool.and(U32.is_le(x, 1114111), U32.is_ge((x - 55296 : U32), 2048)),
8024 x)