def escape.other
yaml-for-bend@0.1.1.0 · emit.bend:60
import yaml-for-bend@0.1.1.0/emit.bend as Emit
import Base
60def escape.other(c: Char) -> String:
61 match c:
62 case Chr{+x}:
63 +n = U32.to_nat(x)
64 Bool.pick(String, U32.is_eq(x, 133), "\\N",
65 Bool.pick(String, U32.is_eq(x, 8232), "\\L",
66 Bool.pick(String, U32.is_eq(x, 8233), "\\P",
67 Bool.pick(String, is_plain.char(x), SCon{Chr{x}, SNil{}},
68 Bool.pick(String, Nat.is_lt(n, 256n), "\\x" ++ hex.text(2n, n), "\\u" ++ hex.text(4n, n))))))