diff options
author | Joey Hess <joey@kitenet.net> | 2011-03-08 18:05:20 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-03-08 18:05:20 -0400 |
commit | 26544de9463291b8185fdd1a7c1b33710ef7db3c (patch) | |
tree | ab7d626afd1908f6f089e154f87e2585dff703d6 /Messages.hs | |
parent | b85c91743c73597f41cae73b042ffa86be929ed3 (diff) |
put in utf8 forcing workaround
Haskell's IO layer crashes on characters > 255 when in a non-unicode (latin1)
locale. Until Haskell gets better behavior, put in an admittedly ugly
workaround for that: git-annex forces utf8 output mode no matter what
locale is selected. So if you use a non-utf8 locale, your filenames with
characters > 127 will not be displayed as you'd expect. But at least it
won't crash.
Diffstat (limited to 'Messages.hs')
-rw-r--r-- | Messages.hs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Messages.hs b/Messages.hs index 90857280a..83b3ecf23 100644 --- a/Messages.hs +++ b/Messages.hs @@ -64,3 +64,12 @@ indent s = join "\n" $ map (\l -> " " ++ l) $ lines s - non-decoded form. -} filePathToString :: FilePath -> String filePathToString = if SysConfig.unicodefilepath then id else UTF8.decodeString + +{- Workaround to avoid crashes displaying filenames containing + - characters > 255 in non-utf8 locales. Force encodings to utf-8, + - even though this may mean some characters in the encoding + - are mangled. -} +forceUtf8 :: IO () +forceUtf8 = do + hSetEncoding stdout utf8 + hSetEncoding stderr utf8 |