From 5bcc09947718bec704ff9561dc193ba3c50a1ccf Mon Sep 17 00:00:00 2001 From: Mateusz Kowalczyk Date: Thu, 13 Mar 2014 21:19:07 +0000 Subject: Always read in prologue files as UTF8 (#286). --- src/Haddock.hs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Haddock.hs b/src/Haddock.hs index e4c7fdc0..67c45362 100644 --- a/src/Haddock.hs +++ b/src/Haddock.hs @@ -4,7 +4,8 @@ -- | -- Module : Haddock -- Copyright : (c) Simon Marlow 2003-2006, --- David Waern 2006-2010 +-- David Waern 2006-2010, +-- Mateusz Kowalczyk 2014 -- License : BSD-like -- -- Maintainer : haddock@projects.haskell.org @@ -447,10 +448,13 @@ getPrologue dflags flags = case [filename | Flag_Prologue filename <- flags ] of [] -> return Nothing [filename] -> do - str <- readFile filename - case parseParasMaybe dflags str of - Nothing -> throwE $ "failed to parse haddock prologue from file: " ++ filename - Just doc -> return (Just doc) + withFile filename ReadMode $ \h -> do + hSetEncoding h utf8 + str <- hGetContents h + case parseParasMaybe dflags str of + Nothing -> + throwE $ "failed to parse haddock prologue from file: " ++ filename + Just doc -> return (Just doc) _otherwise -> throwE "multiple -p/--prologue options" -- cgit v1.2.3