Use T.decodeUtf8 + BS.readFile instead of T.readFile#2637
Conversation
pepeiborra
left a comment
There was a problem hiding this comment.
Sounds like we need to deprecate T.readFile and introduce T.readFileUtf8 ?
But it is more than possible that some users, specially in windows are using a local encoding, even without being aware of it. |
|
Opened #2641 |
No, it's actually vice versa. This PR fixes HLS for people, whose locale is not UTF-8. GHC mandates that source files are in UTF-8 only, but before this PR HLS would try to use a locale encoding instead. |
As documentation (https://hackage.haskell.org/package/text-2.0/docs/Data-Text-IO.html#v:readFile) explains,
T.readFileis almost always a mistake. It's highly unlikely that files we try to read withT.readFileare in a locale encoding and not in UTF-8. Moreover, withtext-2.0fmap T.decodeUtf8 . BS.readFileis up to 10x faster thanT.readFile.