ironpython3 icon indicating copy to clipboard operation
ironpython3 copied to clipboard

Properly handle preferred encoding

Open slozier opened this issue 2 years ago • 0 comments

The builtin open method uses the preferred encoding (which can be obtained via locale.getpreferredencoding(False)) when opening a text file without specifying an encoding. On Linux/macOS this was incorrectly returning Windows code pages. https://github.com/IronLanguages/ironpython3/pull/1528 changes this always return UTF-8 on non-Windows systems. This should be updated to use the proper logic instead.

Additionally, on Windows, Encoding.GetEncoding(0).CodePage is used to get the the ACP which while probably correct, may be overridden via an EncodingProvider. It may be better to rely on GetACP directly...

See https://github.com/IronLanguages/ironpython3/issues/1527 for additional discussion.

slozier avatar Aug 06 '22 21:08 slozier