You probably want to use an encoding such as UTF-8//IGNORE.
let enc = mkTextEncoding "UTF-8//IGNORE"
hSetEncoding stdin enc
see https://www.stackage.org/haddock/lts-15.14/base-4.13.0.0/GHC-IO-Encoding.html#v:mkTextEncoding
You probably want to use an encoding such as UTF-8//IGNORE.
let enc = mkTextEncoding "UTF-8//IGNORE"
hSetEncoding stdin enc
see https://www.stackage.org/haddock/lts-15.14/base-4.13.0.0/GHC-IO-Encoding.html#v:mkTextEncoding