From 12045d84b6f20c9d959f61d376bd89e722f7f50c Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 23 Sep 2012 22:53:34 -0700 Subject: Revert "More intelligent handling of text encodings." This reverts commit 7272735b3d413a644fd9ab01eeae8ae9cd5a925b. --- src/Text/Pandoc/UTF8.hs | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'src/Text/Pandoc/UTF8.hs') diff --git a/src/Text/Pandoc/UTF8.hs b/src/Text/Pandoc/UTF8.hs index 45664892a..aa3a9da04 100644 --- a/src/Text/Pandoc/UTF8.hs +++ b/src/Text/Pandoc/UTF8.hs @@ -25,11 +25,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Stability : alpha Portability : portable -UTF-8 aware string IO functions that will work with GHC 6.12 or 7. -The reading functions first attempt to read UTF-8; if an encoding -error is encountered, the local encoding is used instead. This -should work well in practice because text in other encodings -is usually not valid UTF-8. +UTF-8 aware string IO functions that will work with GHC 6.10, 6.12, or 7. -} module Text.Pandoc.UTF8 ( readFile , writeFile @@ -49,11 +45,10 @@ where #else import Codec.Binary.UTF8.String (encodeString, decodeString) #endif -import Control.Exception (catch, throwIO) -import GHC.IO.Exception (IOException(..), IOErrorType(..)) + import System.IO hiding (readFile, writeFile, getContents, putStr, putStrLn, hPutStr, hPutStrLn, hGetContents) -import Prelude hiding (readFile, writeFile, getContents, putStr, putStrLn, catch ) +import Prelude hiding (readFile, writeFile, getContents, putStr, putStrLn ) import qualified System.IO as IO readFile :: FilePath -> IO String @@ -80,14 +75,7 @@ hPutStrLn :: Handle -> String -> IO () hPutStrLn h s = hSetEncoding h utf8 >> IO.hPutStrLn h s hGetContents :: Handle -> IO String -hGetContents h = do - hSetEncoding h utf8_bom - catch (IO.hGetContents h) $ \e -> - case ioe_type e of - InvalidArgument -> do - hSetEncoding h localeEncoding - IO.hGetContents h - _ -> throwIO e +hGetContents h = hSetEncoding h utf8_bom >> IO.hGetContents h encodePath :: FilePath -> FilePath decodeArg :: String -> String -- cgit v1.2.3