@@ -5,8 +5,11 @@ import ProjectM36.Client
55import ProjectM36.Server.ParseArgs
66import ProjectM36.Server
77import System.IO
8+import GHC.IO.Encoding
89import Options.Applicative
910import System.Exit
11+import System.Environment
12+import Control.Monad
1013#if __GLASGOW_HASKELL__ < 804
1114import Data.Monoid
1215#endif
@@ -86,8 +89,15 @@ printWelcome = do
8689 putStrLn "A full tutorial is available at:"
8790 putStrLn "https://github.com/agentm/project-m36/blob/master/docs/tutd_tutorial.markdown"
8891
92+-- | If the locale is set to ASCII, upgrade it to UTF-8 because tutd outputs UTF-8-encoded attributes. This is especially important in light docker images where the locale data may be missing.
93+setLocaleIfNecessary :: IO ()
94+setLocaleIfNecessary = do
95+ l <- getLocaleEncoding
96+ when (textEncodingName l == "ASCII") (setLocaleEncoding utf8)
97+
8998main :: IO ()
9099main = do
100+ setLocaleIfNecessary
91101 interpreterConfig <- execParser opts
92102 let connInfo = connectionInfoForConfig interpreterConfig
93103 fscheck <- checkFSType (checkFSForConfig interpreterConfig) (fromMaybe NoPersistence (persistenceStrategyForConfig interpreterConfig))