Skip to content
Snippets Groups Projects
Commit c3105be4 authored by Bodigrim's avatar Bodigrim Committed by Marge Bot
Browse files

Documentation for setLocaleEncoding

parent ec9d7e04
No related branches found
No related tags found
No related merge requests found
...@@ -133,10 +133,35 @@ getFileSystemEncoding :: IO TextEncoding ...@@ -133,10 +133,35 @@ getFileSystemEncoding :: IO TextEncoding
getForeignEncoding :: IO TextEncoding getForeignEncoding :: IO TextEncoding
{-# NOINLINE getForeignEncoding #-} {-# NOINLINE getForeignEncoding #-}
-- | @since 4.5.0.0 -- | Set locale encoding for your program. The locale affects
setLocaleEncoding, setFileSystemEncoding, setForeignEncoding :: TextEncoding -> IO () -- how 'Char's are encoded and decoded when serialized to bytes: e. g.,
-- when you read or write files ('System.IO.readFile'', 'System.IO.writeFile')
-- or use standard input/output ('System.IO.getLine', 'System.IO.putStrLn').
-- For instance, if your program prints non-ASCII characters, it is prudent to execute
--
-- > setLocaleEncoding utf8
--
-- This is necessary, but not enough on Windows, where console is
-- a stateful device, which needs to be configured using
-- @System.Win32.Console.setConsoleOutputCP@ and restored back afterwards.
-- These intricacies are covered by
-- <https://hackage.haskell.org/package/code-page code-page> package,
-- which offers a crossplatform @System.IO.CodePage.withCodePage@ bracket.
--
-- Wrong locale encoding typically causes error messages like
-- "invalid argument (cannot decode byte sequence starting from ...)"
-- or "invalid argument (cannot encode character ...)".
--
-- @since 4.5.0.0
setLocaleEncoding :: TextEncoding -> IO ()
{-# NOINLINE setLocaleEncoding #-} {-# NOINLINE setLocaleEncoding #-}
-- | @since 4.5.0.0
setFileSystemEncoding :: TextEncoding -> IO ()
{-# NOINLINE setFileSystemEncoding #-} {-# NOINLINE setFileSystemEncoding #-}
-- | @since 4.5.0.0
setForeignEncoding :: TextEncoding -> IO ()
{-# NOINLINE setForeignEncoding #-} {-# NOINLINE setForeignEncoding #-}
(getLocaleEncoding, setLocaleEncoding) = mkGlobal initLocaleEncoding (getLocaleEncoding, setLocaleEncoding) = mkGlobal initLocaleEncoding
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment