X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Futils%2FEncoding.hs;h=01dd87c94c49d4ec8d869336ff3300e36f12869a;hb=3787d9878e4d62829a555f01b2a4c5866f24f303;hp=152bf3c60eb0d56ba74dce577c28e33ed6e6db20;hpb=0065d5ab628975892cea1ec7303f968c3338cbe1;p=ghc-hetmet.git diff --git a/compiler/utils/Encoding.hs b/compiler/utils/Encoding.hs index 152bf3c..01dd87c 100644 --- a/compiler/utils/Encoding.hs +++ b/compiler/utils/Encoding.hs @@ -1,3 +1,10 @@ +{-# OPTIONS -w #-} +-- The above warning supression flag is a temporary kludge. +-- While working on this module you are encouraged to remove it and fix +-- any warnings in the module. See +-- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings +-- for details + -- ----------------------------------------------------------------------------- -- -- (c) The University of Glasgow, 1997-2006 @@ -26,9 +33,9 @@ module Encoding ( #define COMPILING_FAST_STRING #include "HsVersions.h" import Foreign -import Data.Char ( ord, chr, isDigit, digitToInt, isHexDigit ) -import Numeric ( showHex ) - +import Data.Char ( ord, chr, isDigit, digitToInt, intToDigit, + isHexDigit ) +import Numeric ( showIntAtBase ) import Data.Bits import GHC.Ptr ( Ptr(..) ) import GHC.Base @@ -138,6 +145,7 @@ countUTF8Chars ptr bytes = go ptr 0 unPtr (Ptr a) = a +utf8EncodeChar :: Char -> Ptr Word8 -> IO (Ptr Word8) utf8EncodeChar c ptr = let x = ord c in case () of @@ -281,6 +289,9 @@ encode_ch c = 'z' : if isDigit (head hex_str) then hex_str -- eg. strings of unicode characters come out as 'z1234Uz5678U', we -- could remove the 'U' in the middle (the 'z' works as a separator). + showHex = showIntAtBase 16 intToDigit + -- needed because prior to GHC 6.2, Numeric.showHex added a "0x" prefix + zDecodeString :: EncodedString -> UserString zDecodeString [] = [] zDecodeString ('Z' : d : rest)