def utf8.push
gralha-http-core@0.1.0.0 · http.bend:70
import gralha-http-core@0.1.0.0/http.bend as Http
import Base
70
71def utf8.push(+c: U32, +acc: List<&2, U32>) -> List<&2, U32>:
72 +cont = ((c .&. 63) .|. 128 : U32)
73 when(List<&2, U32>, U32.is_lt(c, 128), _ => c <> acc,
74 _ => when(List<&2, U32>, U32.is_lt(c, 2048),
75 _ => cont <> ((c >> 6n) .|. 192 : U32) <> acc,
76 _ => when(List<&2, U32>, U32.is_lt(c, 65536),
77 _ => cont <> (((c >> 6n) .&. 63) .|. 128 : U32) <> ((c >> 12n) .|. 224 : U32) <> acc,
78 _ => cont <> (((c >> 6n) .&. 63) .|. 128 : U32) <> (((c >> 12n) .&. 63) .|. 128 : U32)
79 <> ((c >> 18n) .|. 240 : U32) <> acc)))