From 27a7ccb940e4911b8b723106c2467a8af00d88b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Stein?= Date: Sun, 28 May 2017 23:00:17 +0200 Subject: [PATCH] Revise fileContentAsString encoding (issue #2) --- IncludeFilter.hs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/IncludeFilter.hs b/IncludeFilter.hs index 00d209b..21b8338 100644 --- a/IncludeFilter.hs +++ b/IncludeFilter.hs @@ -73,12 +73,9 @@ stripPandoc p = Right (Pandoc _ blocks) -> blocks fileContentAsString :: String -> IO String -fileContentAsString file = do - let handle = openFile file ReadMode - fmap (`hSetEncoding` utf8) handle - !contents <- fmap hGetContents handle - fmap hClose handle - contents +fileContentAsString file = withFile file ReadMode $ \handle -> do + hSetEncoding handle utf8 + hGetContents handle fileContentAsBlocks :: String -> IO [Block] fileContentAsBlocks file = do