Copyright | (C) 2016-2017 Ryan Scott |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Ryan Scott |
Stability | Provisional |
Portability | Portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
System.IO.CodePage
Description
Exports functions which adjust code pages on Windows, and do nothing on other operating systems.
Synopsis
- withCP65001 :: IO a -> IO a
- withCP1200 :: IO a -> IO a
- withCP1201 :: IO a -> IO a
- withCP12000 :: IO a -> IO a
- withCP12001 :: IO a -> IO a
- withCP1252 :: IO a -> IO a
- withCodePage :: CodePage -> IO a -> IO a
- withCodePageOptions :: Options -> CodePage -> IO a -> IO a
- type CodePage = Word32
- cp65001 :: CodePage
- cp1200 :: CodePage
- cp1201 :: CodePage
- cp12000 :: CodePage
- cp12001 :: CodePage
- cp1252 :: CodePage
- data Options
- defaultOptions :: Options
- chatty :: Options -> Bool
- nonWindowsBehavior :: Options -> NonWindowsBehavior
- data NonWindowsBehavior
- nonWindowsDoNothing :: NonWindowsBehavior
- nonWindowsFallbackCodePageEncoding :: (CodePage -> TextEncoding) -> NonWindowsBehavior
- defaultFallbackCodePageEncoding :: CodePage -> TextEncoding
Adjusting CodePage
s
withCP65001 :: IO a -> IO a Source #
Sets the code page for an action to UTF-8 as necessary.
withCP1200 :: IO a -> IO a Source #
Sets the code page for an action to UTF-16LE as necessary.
withCP1201 :: IO a -> IO a Source #
Sets the code page for an action to UTF-16BE as necessary.
withCP12000 :: IO a -> IO a Source #
Sets the code page for an action to UTF-32LE as necessary.
withCP12001 :: IO a -> IO a Source #
Sets the code page for an action to UTF-32BE as necessary.
withCP1252 :: IO a -> IO a Source #
Sets the code page for an action to Latin1 as necessary.
withCodePage :: CodePage -> IO a -> IO a Source #
Sets the code page for an action as necessary.
On operating systems besides Windows, this will make an effort to change
the current TextEncoding
to something that is equivalent to the supplied
CodePage
. Currently, the only supported CodePage
s on non-Windows OSes
are cp65001
, cp1200
, cp1201
, cp12000
, and cp12001
. Supplying any
other CodePage
will result in a runtime error on non-Windows OSes. (If you
would like to configure this behavior, use withCodePageOptions
instead.)
withCodePageOptions :: Options -> CodePage -> IO a -> IO a Source #
Sets the code page for an action as necessary. If the Bool
argument is True
,
this function will emit a warning to stderr
indicating that the code page has
been changed. (withCodePage
sets this argument to False
.)
Notable CodePage
s
Options
defaultOptions :: Options Source #
The default Options
:
Options
{chatty
=False
,nonWindowsBehavior
=nonWindowsFallbackCodePageEncoding
defaultFallbackCodePageEncoding
}
Record fields of Options
nonWindowsBehavior :: Options -> NonWindowsBehavior Source #
Configures how withCodePage
and friends should work on non-Windows
operating systems.
NonWindowsBehavior
data NonWindowsBehavior Source #
Specifies how withCodePage
and friends should work on operating systems
other than Windows.
Constructing NonWindowsBehavior
nonWindowsDoNothing :: NonWindowsBehavior Source #
Don't do anything at all on non-Windows OSes.
nonWindowsFallbackCodePageEncoding :: (CodePage -> TextEncoding) -> NonWindowsBehavior Source #
On non-Windows OSes, change the TextEncoding
by converting the
CodePage
argument to a TextEncoding
using the supplied function.
defaultFallbackCodePageEncoding :: CodePage -> TextEncoding Source #
Provides a best-effort attempt to convert a CodePage
to a TextEncoding
on non-Windows OSes. Errors if given a CodePage
that it doesn't know how
to convert.