diff --git a/compiler/GHC/Driver/DynFlags.hs b/compiler/GHC/Driver/DynFlags.hs index 026a953cfd43305d0183781da9900e293cea4cb4..63f2ec15875b992a3a38b93fff2672f537102ca0 100644 --- a/compiler/GHC/Driver/DynFlags.hs +++ b/compiler/GHC/Driver/DynFlags.hs @@ -495,6 +495,8 @@ class ContainsDynFlags t where initDynFlags :: DynFlags -> IO DynFlags initDynFlags dflags = do let + -- This is not bulletproof: we test that 'localeEncoding' is Unicode-capable, + -- but potentially 'hGetEncoding' 'stdout' might be different. Still good enough. canUseUnicode <- do let enc = localeEncoding str = "‘’" (withCString enc str $ \cstr -> diff --git a/docs/users_guide/using.rst b/docs/users_guide/using.rst index ebc3fe06722feb05b9fbc8b996e76ef724c87c11..e3ef975ef2e1a73fce92e60d022cdeeb65261855 100644 --- a/docs/users_guide/using.rst +++ b/docs/users_guide/using.rst @@ -1823,6 +1823,10 @@ GHC can also be configured using various environment variables. .. envvar:: GHC_NO_UNICODE When non-empty, disables Unicode diagnostics output regardless of locale settings. + GHC can usually determine that locale is not Unicode-capable and fallback to ASCII + automatically, but in some corner cases (e. g., when GHC output is redirected) + you might hit ``invalid argument (cannot encode character '\8216')``, + in which case do set ``GHC_NO_UNICODE``. .. envvar:: GHC_CHARENC