From: Max Bolingbroke Date: Sun, 3 Apr 2011 20:55:00 +0000 (+0100) Subject: Fix handling of suffixes for GNU iconv X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=4d3632720af9016d0099896d155e96b0957acd4b;p=ghc-base.git Fix handling of suffixes for GNU iconv --- 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))