From cca80b4a61497000c742e08a6b9d8257ad94f8fa Mon Sep 17 00:00:00 2001 From: josefs Date: Sat, 7 May 2005 12:17:01 +0000 Subject: [PATCH] [project @ 2005-05-07 12:17:01 by josefs] Allow unicode in string and character literals when pretty printing external core. --- ghc/compiler/coreSyn/PprExternalCore.lhs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ghc/compiler/coreSyn/PprExternalCore.lhs b/ghc/compiler/coreSyn/PprExternalCore.lhs index ba592a9..26c89cc 100644 --- a/ghc/compiler/coreSyn/PprExternalCore.lhs +++ b/ghc/compiler/coreSyn/PprExternalCore.lhs @@ -157,11 +157,17 @@ pstring s = doubleQuotes(text (escape s)) escape s = foldr f [] (map ord s) where - f cv rest | (cv < 0x20 || cv > 0x7e || cv == 0x22 || cv == 0x27 || cv == 0x5c) = + f cv rest + | cv > 0xFF = '\\':'x':hs ++ rest + | (cv < 0x20 || cv > 0x7e || cv == 0x22 || cv == 0x27 || cv == 0x5c) = '\\':'x':h1:h0:rest where (q1,r1) = quotRem cv 16 h1 = intToDigit q1 h0 = intToDigit r1 + hs = dropWhile (=='0') $ reverse $ mkHex cv + mkHex 0 = "" + mkHex cv = intToDigit r : mkHex q + where (q,r) = quotRem cv 16 f cv rest = (chr cv):rest \end{code} -- 1.7.10.4