git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
fixes #1265: escape all but printable ASCII (except space) in strings
commit3afc6f33832a443760c9d3378a69071cde3b2be2 authorMichael Ficarra <github@michael.ficarra.me> dateTue 14 Jul 2015, 23:29 (11 years ago) parent08ab297
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)