def esc.c

bend-kit-notch@0.4.0.0 · notch.bend:96

import bend-kit-notch@0.4.0.0/notch.bend as Notch
import Base

96# JSON (RFC 8259 §7): quote, backslash and control chars are escaped.
97def esc.c(+c: U32, rest: String) -> String:
98  match c:
99    case 34:
100      SCon{Chr{92}, SCon{Chr{34}, rest}}
101    case 92:
102      SCon{Chr{92}, SCon{Chr{92}, rest}}
103    case 10:
104      SCon{Chr{92}, SCon{'n', rest}}
105    case 13:
106      SCon{Chr{92}, SCon{'r', rest}}
107    case 9:
108      SCon{Chr{92}, SCon{'t', rest}}
109    case _:
110      esc.ctl(U32.is_lt(c, 32), c, rest)

Uses (8)

Used by (1)