diff options
Diffstat (limited to 'libraries/base/GHC/IO/Encoding.hs')
-rw-r--r-- | libraries/base/GHC/IO/Encoding.hs | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/libraries/base/GHC/IO/Encoding.hs b/libraries/base/GHC/IO/Encoding.hs index 578a420faf..b734f00f5b 100644 --- a/libraries/base/GHC/IO/Encoding.hs +++ b/libraries/base/GHC/IO/Encoding.hs @@ -27,6 +27,7 @@ module GHC.IO.Encoding ( setLocaleEncoding, setFileSystemEncoding, setForeignEncoding, char8, mkTextEncoding, + argvEncoding ) where import GHC.Base @@ -56,7 +57,8 @@ import System.IO.Unsafe (unsafePerformIO) -- | The Latin1 (ISO8859-1) encoding. This encoding maps bytes -- directly to the first 256 Unicode code points, and is thus not a -- complete Unicode encoding. An attempt to write a character greater than --- '\255' to a 'Handle' using the 'latin1' encoding will result in an error. +-- '\255' to a 'System.IO.Handle' using the 'latin1' encoding will result in an +-- error. latin1 :: TextEncoding latin1 = Latin1.latin1_checked @@ -121,7 +123,7 @@ getFileSystemEncoding :: IO TextEncoding -- | The Unicode encoding of the current locale, but where undecodable -- bytes are replaced with their closest visual match. Used for --- the 'CString' marshalling functions in "Foreign.C.String" +-- the 'Foreign.C.String.CString' marshalling functions in "Foreign.C.String" -- -- @since 4.5.0.0 getForeignEncoding :: IO TextEncoding @@ -161,6 +163,17 @@ initFileSystemEncoding = CodePage.mkLocaleEncoding RoundtripFailure initForeignEncoding = CodePage.mkLocaleEncoding IgnoreCodingFailure #endif +-- See Note [Windows Unicode Arguments] in rts/RtsFlags.c +-- On Windows we assume hs_init argv is in utf8 encoding. + +-- | Internal encoding of argv +argvEncoding :: IO TextEncoding +#if defined(mingw32_HOST_OS) +argvEncoding = return utf8 +#else +argvEncoding = getFileSystemEncoding +#endif + -- | An encoding in which Unicode code points are translated to bytes -- by taking the code point modulo 256. When decoding, bytes are -- translated directly into the equivalent code point. @@ -175,7 +188,7 @@ char8 = Latin1.latin1 -- | Look up the named Unicode encoding. May fail with -- --- * 'isDoesNotExistError' if the encoding is unknown +-- * 'System.IO.Error.isDoesNotExistError' if the encoding is unknown -- -- The set of known encodings is system-dependent, but includes at least: -- |