git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
C++: escape control chars when rendering
commit03eead33cf9f78658d5fbde25f405fd57da631dd authorAndy Arvanitis <andyarvanitis@gmail.com> dateThu 26 Jan 2017, 21:28 (10 years ago) parente81fecf
1 file changed+2
src/Language/PureScript/Pretty/Cpp.hs+2
src/Language/PureScript/Pretty/Cpp.hs+2
@@ -31,6 +31,7 @@ import Data.Maybe (fromMaybe)
3131import Data.Text (Text)
3232import qualified Data.Text as T
3333import Data.Monoid ((<>))
34+import Numeric (showHex)
3435
3536#if __GLASGOW_HASKELL__ < 710
3637import Control.Applicative
@@ -410,6 +411,7 @@ encodeChar '\r' = "\\r"
410411encodeChar '"' = "\\\""
411412encodeChar '\'' = "\\'"
412413encodeChar '\\' = "\\\\"
414+encodeChar c | isControl c = T.pack $ "\\x" ++ showHex (fromEnum c) ""
413415encodeChar c = T.singleton c
414416
415417-- Note: Any lone surrogates will be replaced with U+FFFD