From 4d3632720af9016d0099896d155e96b0957acd4b Mon Sep 17 00:00:00 2001 From: Max Bolingbroke Date: Sun, 3 Apr 2011 21:55:00 +0100 Subject: [PATCH] Fix handling of suffixes for GNU iconv --- GHC/IO/Encoding/Iconv.hs | 9 +++++++-- 1 file 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)) -- 1.7.10.4