diff options
author | Simon Marlow <marlowsd@gmail.com> | 2009-08-26 10:40:52 +0000 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2009-08-26 10:40:52 +0000 |
commit | 3ce0e4990f5a40dd989435b41cad279d347a047d (patch) | |
tree | 3a06516c6215cb82f78efa4067fce3d4998ffa8d /compiler/utils/Pretty.lhs | |
parent | d20d32d788e2d6c088e6b03776c428df5bb004d3 (diff) | |
download | haskell-3ce0e4990f5a40dd989435b41cad279d347a047d.tar.gz |
Fix part of #3398: pretty-printing always goes via the I/O library encoding
That is, unless we're printing in LeftMode, where we bypass encoding
for speed. This is safe, because LeftMode is used for outputting C or
asm, where everyting is Z-encoded and hence ASCII.
Error messages and other compiler output containing Unicode will now
appear correctly according to the locale settings.
Diffstat (limited to 'compiler/utils/Pretty.lhs')
-rw-r--r-- | compiler/utils/Pretty.lhs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/compiler/utils/Pretty.lhs b/compiler/utils/Pretty.lhs index 47d4b1e19e..3c003987af 100644 --- a/compiler/utils/Pretty.lhs +++ b/compiler/utils/Pretty.lhs @@ -1000,10 +1000,6 @@ spaces n | n <=# _ILIT(0) = "" pprCols :: Int pprCols = 100 -- could make configurable --- NB. printDoc prints FastStrings in UTF-8: hPutFS below does no decoding. --- This is what we usually want, because the IO library has no encoding --- functionality, and we're assuming UTF-8 source code so we might as well --- assume UTF-8 output too. printDoc :: Mode -> Handle -> Doc -> IO () printDoc LeftMode hdl doc = do { printLeftRender hdl doc; hFlush hdl } @@ -1013,7 +1009,9 @@ printDoc mode hdl doc where put (Chr c) next = hPutChar hdl c >> next put (Str s) next = hPutStr hdl s >> next - put (PStr s) next = hPutFS hdl s >> next + put (PStr s) next = hPutStr hdl (unpackFS s) >> next + -- NB. not hPutFS, we want this to go through + -- the I/O library's encoding layer. (#3398) put (LStr s l) next = hPutLitString hdl s l >> next done = hPutChar hdl '\n' |