def json.char
import yaml-for-bend@0.1.1.0/value.bend as Valueimport Base
238def json.char(c: Char) -> String:
239 match c:
240 case '"':
241 "\\\""
242 case '\\':
243 "\\\\"
244 case '\n':
245 "\\n"
246 case '\t':
247 "\\t"
248 case '\r':
249 "\\r"
250 case Chr{+x}:
251 Bool.pick(String, U32.is_lt(x, 32), "\\u00" ++ SCon{hex.digit(U32.to_nat(U32.div(x, 16))), SCon{hex.digit(U32.to_nat(U32.mod(x, 16))), SNil{}}},
252 SCon{Chr{x}, SNil{}})