ref: 90dc5f51483723b1cd8604d749ef3158d55c21ca
parent: 05f6c77db23d5387751e832de578afcfea703478
author: Ori Bernstein <ori@eigenstate.org>
date: Mon Jul 4 11:23:58 EDT 2016
Make escaped strings a bit friendlier.
--- a/lib/std/fmt.myr
+++ b/lib/std/fmt.myr
@@ -509,8 +509,19 @@
if isprint(b)
sbputb(sb, b)
else
- sbputs(sb, "\\x")
- intfmt(sb, [.padto=2, .padfill='0', .base=16], false, b)
+ match (b : char)
+ | '\n': sbputs(sb, "\\n")
+ | '\r': sbputs(sb, "\\r")
+ | '\t': sbputs(sb, "\\t")
+ | '\b': sbputs(sb, "\\b")
+ | '\"': sbputs(sb, "\\\"")
+ | '\'': sbputs(sb, "\\\'")
+ | '\\': sbputs(sb, "\\\\")
+ | '\0': sbputs(sb, "\\0")
+ | _:
+ sbputs(sb, "\\x")
+ intfmt(sb, [.padto=2, .padfill='0', .base=16], false, b)
+ ;;
;;
;;
else