projects
/
ghc-base.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix silly mistake in hGetBufSome (#4895)
[ghc-base.git]
/
GHC
/
IO
/
Encoding.hs
diff --git
a/GHC/IO/Encoding.hs
b/GHC/IO/Encoding.hs
index
7763ce4
..
44cdd86
100644
(file)
--- a/
GHC/IO/Encoding.hs
+++ b/
GHC/IO/Encoding.hs
@@
-1,4
+1,4
@@
-{-# OPTIONS_GHC -fno-implicit-prelude -funbox-strict-fields #-}
+{-# OPTIONS_GHC -XNoImplicitPrelude -funbox-strict-fields #-}
-----------------------------------------------------------------------------
-- |
-- Module : GHC.IO.Encoding
-----------------------------------------------------------------------------
-- |
-- Module : GHC.IO.Encoding
@@
-30,6
+30,9
@@
import GHC.IO.Encoding.Types
import GHC.Word
#if !defined(mingw32_HOST_OS)
import qualified GHC.IO.Encoding.Iconv as Iconv
import GHC.Word
#if !defined(mingw32_HOST_OS)
import qualified GHC.IO.Encoding.Iconv as Iconv
+#else
+import qualified GHC.IO.Encoding.CodePage as CodePage
+import Text.Read (reads)
#endif
import qualified GHC.IO.Encoding.Latin1 as Latin1
import qualified GHC.IO.Encoding.UTF8 as UTF8
#endif
import qualified GHC.IO.Encoding.Latin1 as Latin1
import qualified GHC.IO.Encoding.UTF8 as UTF8
@@
-96,7
+99,7
@@
localeEncoding :: TextEncoding
#if !defined(mingw32_HOST_OS)
localeEncoding = Iconv.localeEncoding
#else
#if !defined(mingw32_HOST_OS)
localeEncoding = Iconv.localeEncoding
#else
-localeEncoding = Latin1.latin1
+localeEncoding = CodePage.localeEncoding
#endif
-- | Look up the named Unicode encoding. May fail with
#endif
-- | Look up the named Unicode encoding. May fail with
@@
-122,6
+125,9
@@
localeEncoding = Latin1.latin1
-- * a suffix of @\/\/TRANSLIT@ will choose a replacement character
-- for illegal sequences or code points.
--
-- * a suffix of @\/\/TRANSLIT@ will choose a replacement character
-- for illegal sequences or code points.
--
+-- On Windows, you can access supported code pages with the prefix
+-- @CP@; for example, @\"CP1250\"@.
+--
mkTextEncoding :: String -> IO TextEncoding
#if !defined(mingw32_HOST_OS)
mkTextEncoding = Iconv.mkTextEncoding
mkTextEncoding :: String -> IO TextEncoding
#if !defined(mingw32_HOST_OS)
mkTextEncoding = Iconv.mkTextEncoding
@@
-133,6
+139,8
@@
mkTextEncoding "UTF-16BE" = return utf16be
mkTextEncoding "UTF-32" = return utf32
mkTextEncoding "UTF-32LE" = return utf32le
mkTextEncoding "UTF-32BE" = return utf32be
mkTextEncoding "UTF-32" = return utf32
mkTextEncoding "UTF-32LE" = return utf32le
mkTextEncoding "UTF-32BE" = return utf32be
+mkTextEncoding ('C':'P':n)
+ | [(cp,"")] <- reads n = return $ CodePage.codePageEncoding cp
mkTextEncoding e = ioException
(IOError Nothing NoSuchThing "mkTextEncoding"
("unknown encoding:" ++ e) Nothing Nothing)
mkTextEncoding e = ioException
(IOError Nothing NoSuchThing "mkTextEncoding"
("unknown encoding:" ++ e) Nothing Nothing)