haskell/cabal — pull request #1743 by ianbollinger (2014-04-01 01:57:36+00:00)
Title: Relax handling of encoding failures on Windows (fixes #846)

This uses @batterseapower's suggestion of using `TransliterateCodingFailure` by default for `stderr` and `stdout`. @dcoutts was concerned that doing so might break applications parsing Cabal's output, but it still seems to do the right thing. As an additional check out of paranoia, the original behavior is retained if the current locale encoding is a Unicode encoding (which may be entirely unnecessary.)

While this fixes #846, it only is a first step toward resolving #650 and #1583. Cabal will try to write Windows paths (Unicode) to the configuration file using the current locale encoding (via `writeFile`), which then fails. I suppose the two solutions would be to either escape any unrepresentable characters in the paths or unconditionally read/write the configuration file in UTF-8 (potentially problematic for backwards compatibility.) Thoughts?

Finally, it's possible that the error-handling changes to `stderr`/`stdout` should also be applied to `Distribution.Simple` in case encoding errors spring up there too.