def utf8.width
import emerging-ezhttp@0.21.0.0/src/http.bend as Httpimport Base
126# octets one code point takes in UTF-8, for a text written onto the wire
127# (RFC 3629 §3). Content-Length counts octets (RFC 9110 §8.6); a Bend String
128# counts code points.
129def utf8.width(+u: U32) -> Nat:
130 Bool.pick(Nat, U32.is_lt(u, 128), 1n,
131 Bool.pick(Nat, U32.is_lt(u, 2048), 2n,
132 Bool.pick(Nat, U32.is_lt(u, 65536), 3n, 4n)))