summaryrefslogtreecommitdiff
path: root/libraries/ghc-boot/GHC/Utils/Encoding.hs
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/ghc-boot/GHC/Utils/Encoding.hs')
-rw-r--r--libraries/ghc-boot/GHC/Utils/Encoding.hs6
1 files changed, 4 insertions, 2 deletions
diff --git a/libraries/ghc-boot/GHC/Utils/Encoding.hs b/libraries/ghc-boot/GHC/Utils/Encoding.hs
index 183d29946f..044ce06d55 100644
--- a/libraries/ghc-boot/GHC/Utils/Encoding.hs
+++ b/libraries/ghc-boot/GHC/Utils/Encoding.hs
@@ -145,8 +145,10 @@ encode_ch '%' = "zv"
encode_ch c = encode_as_unicode_char c
encode_as_unicode_char :: Char -> EncodedString
-encode_as_unicode_char c = 'z' : if isDigit (head hex_str) then hex_str
- else '0':hex_str
+encode_as_unicode_char c = 'z' : case hex_str of
+ hd : _
+ | isDigit hd -> hex_str
+ _ -> '0' : hex_str
where hex_str = showHex (ord c) "U"
-- ToDo: we could improve the encoding here in various ways.
-- eg. strings of unicode characters come out as 'z1234Uz5678U', we