[commit: base] master: Fix handling of suffixes for GNU iconv (4d36327)

Max Bolingbroke batterseapower at hotmail.com
Sun Apr 3 22:55:46 CEST 2011


Repository : ssh://darcs.haskell.org//srv/darcs/packages/base

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/4d3632720af9016d0099896d155e96b0957acd4b

>---------------------------------------------------------------

commit 4d3632720af9016d0099896d155e96b0957acd4b
Author: Max Bolingbroke <batterseapower at hotmail.com>
Date:   Sun Apr 3 21:55:00 2011 +0100

    Fix handling of suffixes for GNU iconv

>---------------------------------------------------------------

 GHC/IO/Encoding/Iconv.hs |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/GHC/IO/Encoding/Iconv.hs b/GHC/IO/Encoding/Iconv.hs
index 0316698..440344a 100644
--- a/GHC/IO/Encoding/Iconv.hs
+++ b/GHC/IO/Encoding/Iconv.hs
@@ -41,6 +41,7 @@ import Data.Maybe
 import GHC.Base
 import GHC.IO.Buffer
 import GHC.IO.Encoding.Types
+import GHC.List (span)
 import GHC.Num
 import GHC.Show
 import GHC.Real
@@ -138,8 +139,12 @@ mkTextEncoding :: String -> IO TextEncoding
 mkTextEncoding charset = do
   return (TextEncoding { 
                 textEncodingName = charset,
-		mkTextDecoder = newIConv charset haskellChar iconvDecode,
-		mkTextEncoder = newIConv haskellChar charset iconvEncode})
+		mkTextDecoder = newIConv raw_charset (haskellChar ++ suffix) (iconvDecode cfm),
+		mkTextEncoder = newIConv haskellChar charset (iconvEncode cfm)})
+  where
+    -- An annoying feature of GNU iconv is that the //PREFIXES only take
+    -- effect when they appear on the tocode parameter to iconv_open:
+    (raw_charset, suffix) = span (/= '/') charset
 
 newIConv :: String -> String
    -> (IConv -> Buffer a -> Buffer b -> IO (Buffer a, Buffer b))





More information about the Libraries mailing list