setLocaleEncoding is supposed to set an encoding that is used by default for all opened Handles. And by default the encoding is set based on the locale settings. But file-io does not use that encoding:
ghci> System.IO.withFile ("/etc/passwd") ReadMode (\h -> print =<< hGetEncoding h)
Just UTF-8
ghci> import System.OsPath
ghci> f <- encodeFS "/etc/passwd"
ghci> System.File.OsPath.withFile f ReadMode (\h -> print =<< hGetEncoding h)
Nothing
This means that, when converting existing code from FilePath to OsPath, any use of file-io for opening a Handle that is used with String based operations risks introducing a bug.