Skip to content

Commit 6dc17e1

Browse files
committed
don't ASCII-encode unicode
1 parent 488948e commit 6dc17e1

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/CodeGen/SExpr.hs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,16 @@ prettySexp t = flatPrint printer . toSexp t
3737
ANode kw -> kw
3838
AInt i -> pack $ show i
3939
ABool b -> if b then "true" else "false"
40-
AString str -> pack $ show str
40+
AString str -> pack $ quote str
41+
42+
-- wraps a string between double quotes, and escapes it
43+
-- NOTE: there probably never are double quotes in the string, but regardless
44+
quote :: String -> String
45+
quote s = "\"" <> escape s <> "\""
46+
where
47+
escape [] = []
48+
escape ('"':cs) = "\\\"" <> escape cs
49+
escape (c :cs) = c : escape cs
4150

4251

4352
class ToSexp t a where

0 commit comments

Comments
 (0)