-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Windows code page library for Haskell
--   
--   This library provides two modules:
--   
--   <ul>
--   <li><a>System.IO.CodePage</a>: a cross-platform module that exports
--   functions which adjust code pages on Windows, and do nothing on other
--   operating systems.</li>
--   <li><a>System.Win32.CodePage</a>: On Windows, this exports functions
--   for getting, setting, and analyzing code pages. On other operating
--   systems, this module exports nothing.</li>
--   </ul>
@package code-page
@version 0.2


-- | Various internals used by <a>System.IO.CodePage</a>.
--   
--   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.
module System.IO.CodePage.Internal

-- | A numeric type representing Windows code pages.
type CodePage = Word32

-- | The UTF-8 code page.
cp65001 :: CodePage

-- | The UTF-16LE code page.
cp1200 :: CodePage

-- | The UTF-16BE code page.
cp1201 :: CodePage

-- | The UTF-32LE code page.
cp12000 :: CodePage

-- | The UTF-32BE code page.
cp12001 :: CodePage

-- | The Latin1 code page.
cp1252 :: CodePage

-- | Options that specify how <tt>withCodePage</tt> and friends should
--   work.
data Options
Options :: Bool -> NonWindowsBehavior -> Options

-- | If <a>True</a>, emit a warning to <tt>stderr</tt> indicating that the
--   code page has been changed. If <a>False</a>, don't emit any warnings.
[chatty] :: Options -> Bool

-- | Configures how <tt>withCodePage</tt> and friends should work on
--   non-Windows operating systems.
[nonWindowsBehavior] :: Options -> NonWindowsBehavior

-- | The default <a>Options</a>:
--   
--   <pre>
--   <a>Options</a>
--   { <a>chatty</a> = <a>False</a>
--   , <a>nonWindowsBehavior</a> =
--       <a>nonWindowsFallbackCodePageEncoding</a> <a>defaultFallbackCodePageEncoding</a>
--   }
--   </pre>
defaultOptions :: Options

-- | Specifies how <tt>withCodePage</tt> and friends should work on
--   operating systems other than Windows.
data NonWindowsBehavior

-- | Don't do anything at all on non-Windows OSes.
NonWindowsDoNothing :: NonWindowsBehavior

-- | On non-Windows OSes, change the <a>TextEncoding</a> by converting the
--   <a>CodePage</a> argument to a <a>TextEncoding</a> using the supplied
--   function.
NonWindowsFallbackCodePageEncoding :: (CodePage -> TextEncoding) -> NonWindowsBehavior

-- | Don't do anything at all on non-Windows OSes.
nonWindowsDoNothing :: NonWindowsBehavior

-- | On non-Windows OSes, change the <a>TextEncoding</a> by converting the
--   <a>CodePage</a> argument to a <a>TextEncoding</a> using the supplied
--   function.
nonWindowsFallbackCodePageEncoding :: (CodePage -> TextEncoding) -> NonWindowsBehavior

-- | Provides a best-effort attempt to convert a <a>CodePage</a> to a
--   <a>TextEncoding</a> on non-Windows OSes. Errors if given a
--   <a>CodePage</a> that it doesn't know how to convert.
defaultFallbackCodePageEncoding :: CodePage -> TextEncoding


-- | Exports functions which adjust code pages on Windows, and do nothing
--   on other operating systems.
module System.IO.CodePage

-- | Sets the code page for an action to UTF-8 as necessary.
withCP65001 :: IO a -> IO a

-- | Sets the code page for an action to UTF-16LE as necessary.
withCP1200 :: IO a -> IO a

-- | Sets the code page for an action to UTF-16BE as necessary.
withCP1201 :: IO a -> IO a

-- | Sets the code page for an action to UTF-32LE as necessary.
withCP12000 :: IO a -> IO a

-- | Sets the code page for an action to UTF-32BE as necessary.
withCP12001 :: IO a -> IO a

-- | Sets the code page for an action to Latin1 as necessary.
withCP1252 :: IO a -> IO a

-- | Sets the code page for an action as necessary.
--   
--   On operating systems besides Windows, this will make an effort to
--   change the current <a>TextEncoding</a> to something that is equivalent
--   to the supplied <a>CodePage</a>. Currently, the only supported
--   <a>CodePage</a>s on non-Windows OSes are <a>cp65001</a>,
--   <a>cp1200</a>, <a>cp1201</a>, <a>cp12000</a>, and <a>cp12001</a>.
--   Supplying any other <a>CodePage</a> will result in a runtime error on
--   non-Windows OSes. (If you would like to configure this behavior, use
--   <a>withCodePageOptions</a> instead.)
withCodePage :: CodePage -> IO a -> IO a

-- | Sets the code page for an action as necessary. If the <a>Bool</a>
--   argument is <a>True</a>, this function will emit a warning to
--   <tt>stderr</tt> indicating that the code page has been changed.
--   (<a>withCodePage</a> sets this argument to <a>False</a>.)
withCodePageOptions :: Options -> CodePage -> IO a -> IO a

-- | A numeric type representing Windows code pages.
type CodePage = Word32

-- | The UTF-8 code page.
cp65001 :: CodePage

-- | The UTF-16LE code page.
cp1200 :: CodePage

-- | The UTF-16BE code page.
cp1201 :: CodePage

-- | The UTF-32LE code page.
cp12000 :: CodePage

-- | The UTF-32BE code page.
cp12001 :: CodePage

-- | The Latin1 code page.
cp1252 :: CodePage

-- | Options that specify how <tt>withCodePage</tt> and friends should
--   work.
data Options

-- | The default <a>Options</a>:
--   
--   <pre>
--   <a>Options</a>
--   { <a>chatty</a> = <a>False</a>
--   , <a>nonWindowsBehavior</a> =
--       <a>nonWindowsFallbackCodePageEncoding</a> <a>defaultFallbackCodePageEncoding</a>
--   }
--   </pre>
defaultOptions :: Options

-- | If <a>True</a>, emit a warning to <tt>stderr</tt> indicating that the
--   code page has been changed. If <a>False</a>, don't emit any warnings.
chatty :: Options -> Bool

-- | Configures how <tt>withCodePage</tt> and friends should work on
--   non-Windows operating systems.
nonWindowsBehavior :: Options -> NonWindowsBehavior

-- | Specifies how <tt>withCodePage</tt> and friends should work on
--   operating systems other than Windows.
data NonWindowsBehavior

-- | Don't do anything at all on non-Windows OSes.
nonWindowsDoNothing :: NonWindowsBehavior

-- | On non-Windows OSes, change the <a>TextEncoding</a> by converting the
--   <a>CodePage</a> argument to a <a>TextEncoding</a> using the supplied
--   function.
nonWindowsFallbackCodePageEncoding :: (CodePage -> TextEncoding) -> NonWindowsBehavior

-- | Provides a best-effort attempt to convert a <a>CodePage</a> to a
--   <a>TextEncoding</a> on non-Windows OSes. Errors if given a
--   <a>CodePage</a> that it doesn't know how to convert.
defaultFallbackCodePageEncoding :: CodePage -> TextEncoding


-- | On Windows, this exports functions for getting, setting, and analyzing
--   code pages. On other operating systems, this exports nothing.
module System.Win32.CodePage
