From 331923fd7adec11980e776dd33442c654cca0280 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Fri, 11 Jul 2008 15:11:16 +0000 Subject: [PATCH] FIX #2302: print FastStrings in UTF-8 in error messages This is all a bit of a mess, but can hopefully be improved when we get encoding/decoding support in Handles. --- compiler/main/DynFlags.hs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index 3e030f2..18c5f89 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -83,7 +83,7 @@ import Control.Monad ( when ) import Data.Char import System.FilePath -import System.IO ( hPutStrLn, stderr ) +import System.IO ( stderr, hPutChar ) -- ----------------------------------------------------------------------------- -- DynFlags @@ -595,9 +595,14 @@ defaultDynFlags = log_action = \severity srcSpan style msg -> case severity of - SevInfo -> hPutStrLn stderr (show (msg style)) - SevFatal -> hPutStrLn stderr (show (msg style)) - _ -> hPutStrLn stderr ('\n':show ((mkLocMessage srcSpan msg) style)) + SevInfo -> printErrs (msg style) + SevFatal -> printErrs (msg style) + _ -> do + hPutChar stderr '\n' + printErrs ((mkLocMessage srcSpan msg) style) + -- careful (#2302): printErrs prints in UTF-8, whereas + -- converting to string first and using hPutStr would + -- just emit the low 8 bits of each unicode char. } {- -- 1.7.10.4