Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
When we try to read a file that is encoded in UTF-8, and the system locale is not set to UTF-8, the GHC runtime system will throw an error:
https://github.com/jaspervdj/patat/issues/127
However, we don't want to force people to use UTF-8 for everything. So what we do is provide a replacement readFile, which first tries to read the file in the system locale, and then falls back to forcing UTF-8.
If we forced UTF-8, we also want to propagate that to the output handle; otherwise will get errors when we try to display these characters; so withHandle should be used on the output handle (typically stdout).
Documentation
data EncodingFallback Source #
Instances
Show EncodingFallback Source # | |
Defined in Patat.EncodingFallback showsPrec :: Int -> EncodingFallback -> ShowS # show :: EncodingFallback -> String # showList :: [EncodingFallback] -> ShowS # | |
Eq EncodingFallback Source # | |
Defined in Patat.EncodingFallback (==) :: EncodingFallback -> EncodingFallback -> Bool # (/=) :: EncodingFallback -> EncodingFallback -> Bool # |
withHandle :: Handle -> EncodingFallback -> IO a -> IO a Source #