aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk>2014-03-13 21:19:07 +0000
committerMateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk>2014-03-13 21:19:07 +0000
commit5bcc09947718bec704ff9561dc193ba3c50a1ccf (patch)
treead6047e1d7fb5377d7599e7cacade72dc3589221
parent385db9ab8cec14b21c06632eb1fcbe14ac3c3859 (diff)
Always read in prologue files as UTF8 (#286).
-rw-r--r--CHANGES4
-rw-r--r--src/Haddock.hs14
2 files changed, 13 insertions, 5 deletions
diff --git a/CHANGES b/CHANGES
index a98a0e06..c59051a6 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+Changes in version 2.15.0
+
+ * Always read in prologue files as UTF8 (#286 and Cabal #1721)
+
Changes in version 2.14.1
* Render * and -> with their UnicodeSyntax equivalents if -U is enabled
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"