System.IO.CodePage.Internal

code-page-0.2.1: Windows code page library for Haskell

Copyright | (C) 2018 Ryan Scott
License | BSD-style (see the file LICENSE)
Maintainer | Ryan Scott
Stability | Experimental
Portability | Portable
Safe Haskell | Safe-Inferred
Language | Haskell2010

System.IO.CodePage.Internal

Description

Various internals used by System.IO.CodePage.

Note that this is an internal module, and as such, the API presented here is not guaranteed to be stable, even between minor releases of this library.

Synopsis

- type CodePage = Word32
- cp65001 :: CodePage
- cp1200 :: CodePage
- cp1201 :: CodePage
- cp12000 :: CodePage
- cp12001 :: CodePage
- cp1252 :: CodePage
- data Options = Options {
  - chatty :: Bool
  - nonWindowsBehavior :: NonWindowsBehavior
  }
- defaultOptions :: Options
- data NonWindowsBehavior
  - = NonWindowsDoNothing
  - | NonWindowsFallbackCodePageEncoding (CodePage -> TextEncoding)
- nonWindowsDoNothing :: NonWindowsBehavior
- nonWindowsFallbackCodePageEncoding :: (CodePage -> TextEncoding) -> NonWindowsBehavior
- defaultFallbackCodePageEncoding :: CodePage -> TextEncoding

# Documentation

type CodePage = Word32 #

A numeric type representing Windows code pages.

cp65001 :: CodePage #

The UTF-8 code page.

cp1200 :: CodePage #

The UTF-16LE code page.

cp1201 :: CodePage #

The UTF-16BE code page.

cp12000 :: CodePage #

The UTF-32LE code page.

cp12001 :: CodePage #

The UTF-32BE code page.

cp1252 :: CodePage #

The Latin1 code page.

data Options #

Options that specify how `withCodePage` and friends should work.

Constructors

Options |
Fields chatty :: Bool If `True`, emit a warning to `stderr` indicating that the code page has been changed. If `False`, don't emit any warnings. nonWindowsBehavior :: NonWindowsBehavior Configures how `withCodePage` and friends should work on non-Windows operating systems.

defaultOptions :: Options #

The default `Options`:

    Options
    { chatty = False
    , nonWindowsBehavior =
        nonWindowsFallbackCodePageEncoding defaultFallbackCodePageEncoding
    }

data NonWindowsBehavior #

Specifies how `withCodePage` and friends should work on operating systems other than Windows.

Constructors

NonWindowsDoNothing | Don't do anything at all on non-Windows OSes.
NonWindowsFallbackCodePageEncoding (CodePage -> TextEncoding) | On non-Windows OSes, change the `TextEncoding` by converting the `CodePage` argument to a `TextEncoding` using the supplied function.

nonWindowsDoNothing :: NonWindowsBehavior #

Don't do anything at all on non-Windows OSes.

nonWindowsFallbackCodePageEncoding :: (CodePage -> TextEncoding) -> NonWindowsBehavior #

On non-Windows OSes, change the `TextEncoding` by converting the `CodePage` argument to a `TextEncoding` using the supplied function.

defaultFallbackCodePageEncoding :: CodePage -> TextEncoding #

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.