patat-0.13.0.0: Terminal-based presentations using Pandoc
Safe HaskellSafe-Inferred
LanguageHaskell2010

Patat.EncodingFallback

Description

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