Skip to content
This repository has been archived by the owner on Aug 3, 2024. It is now read-only.

Avoid errors on non UTF-8 Windows #566

Merged
merged 2 commits into from
Jul 4, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions haddock-api/src/Haddock/Interface.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
-----------------------------------------------------------------------------
-- |
-- Module : Haddock.Interface
Expand Down Expand Up @@ -48,14 +49,20 @@ import qualified Data.Set as Set
import Distribution.Verbosity
import System.Directory
import System.FilePath
import System.IO
import Text.Printf

import Digraph
import DynFlags hiding (verbosity)
import Exception
import GHC hiding (verbosity)
#if defined(mingw32_HOST_OS)
import GHC.IO.Encoding.CodePage (mkLocaleEncoding)
import GHC.IO.Encoding.Failure (CodingFailureMode(TransliterateCodingFailure))
#endif
import HscTypes
import FastString (unpackFS)
import MonadUtils (liftIO)

-- | Create 'Interface's and a link environment by typechecking the list of
-- modules using the GHC API and processing the resulting syntax trees.
Expand All @@ -68,6 +75,10 @@ processModules
-> Ghc ([Interface], LinkEnv) -- ^ Resulting list of interfaces and renaming
-- environment
processModules verbosity modules flags extIfaces = do
#if defined(mingw32_HOST_OS)
-- Avoid internal error: <stderr>: hPutChar: invalid argument (invalid character)' non UTF-8 Windows
liftIO $ hSetEncoding stderr $ mkLocaleEncoding TransliterateCodingFailure
#endif

out verbosity verbose "Creating interfaces..."
let instIfaceMap = Map.fromList [ (instMod iface, iface) | ext <- extIfaces
Expand Down