git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #1266 from michaelficarra/patch-3

fixes #1265: escape all but printable ASCII (except space) in strings

commitff27224a36737b7158d090cfd52018aba95a1e34 authorPhil Freeman <paf31@cantab.net> dateSat 8 Aug 2015, 15:10 (11 years ago) parent546bc843afc6f3
1 file changed+1
src/Language/PureScript/Pretty/JS.hs+1
src/Language/PureScript/Pretty/JS.hs+1
@@ -163,6 +163,7 @@ string s = '"' : concatMap encodeChar s ++ "\""
163163 encodeChar '\\' = "\\\\"
164164 encodeChar c | fromEnum c > 0xFFF = "\\u" ++ showHex (fromEnum c) ""
165165 encodeChar c | fromEnum c > 0xFF = "\\u0" ++ showHex (fromEnum c) ""
166+ encodeChar c | fromEnum c > 0x7E || fromEnum c < 0x20 = "\\x" ++ showHex (fromEnum c) ""
166167 encodeChar c = [c]
167168
168169conditional :: Pattern PrinterState JS ((JS, JS), JS)