<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>GHC.IO.Encoding.Types</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[ window.onload = function () {pageLoad();setSynopsis("mini_GHC-IO-Encoding-Types.html");}; //]]> </script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/GHC-IO-Encoding-Types.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">base-4.3.1.0: Basic libraries</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Portability</th><td>non-portable</td></tr><tr><th>Stability</th><td>internal</td></tr><tr><th>Maintainer</th><td>libraries@haskell.org</td></tr></table><p class="caption">GHC.IO.Encoding.Types</p></div><div id="description"><p class="caption">Description</p><div class="doc"><p>Types for text encoding/decoding </p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><span class="keyword">data</span> <a href="#t:BufferCodec">BufferCodec</a> from to state = <a href="#v:BufferCodec">BufferCodec</a> {<ul class="subs"><li><a href="#v:encode">encode</a> :: <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> from -> <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> to -> <a href="System-IO.html#t:IO">IO</a> (<a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> from, <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> to)</li><li><a href="#v:close">close</a> :: <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></li><li><a href="#v:getState">getState</a> :: <a href="System-IO.html#t:IO">IO</a> state</li><li><a href="#v:setState">setState</a> :: state -> <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></li></ul>}</li><li class="src short"><span class="keyword">data</span> <a href="#t:TextEncoding">TextEncoding</a> = <span class="keyword">forall</span> dstate estate . <a href="#v:TextEncoding">TextEncoding</a> {<ul class="subs"><li><a href="#v:textEncodingName">textEncodingName</a> :: <a href="Data-Char.html#t:String">String</a></li><li><a href="#v:mkTextDecoder">mkTextDecoder</a> :: <a href="System-IO.html#t:IO">IO</a> (<a href="GHC-IO-Encoding-Types.html#t:TextDecoder">TextDecoder</a> dstate)</li><li><a href="#v:mkTextEncoder">mkTextEncoder</a> :: <a href="System-IO.html#t:IO">IO</a> (<a href="GHC-IO-Encoding-Types.html#t:TextEncoder">TextEncoder</a> estate)</li></ul>}</li><li class="src short"><span class="keyword">type</span> <a href="#t:TextEncoder">TextEncoder</a> state = <a href="GHC-IO-Encoding-Types.html#t:BufferCodec">BufferCodec</a> <a href="GHC-IO-Buffer.html#t:CharBufElem">CharBufElem</a> <a href="Data-Word.html#t:Word8">Word8</a> state</li><li class="src short"><span class="keyword">type</span> <a href="#t:TextDecoder">TextDecoder</a> state = <a href="GHC-IO-Encoding-Types.html#t:BufferCodec">BufferCodec</a> <a href="Data-Word.html#t:Word8">Word8</a> <a href="GHC-IO-Buffer.html#t:CharBufElem">CharBufElem</a> state</li><li class="src short"><span class="keyword">type</span> <a href="#t:EncodeBuffer">EncodeBuffer</a> = <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Char.html#t:Char">Char</a> -> <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a> -> <a href="System-IO.html#t:IO">IO</a> (<a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Char.html#t:Char">Char</a>, <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a>)</li><li class="src short"><span class="keyword">type</span> <a href="#t:DecodeBuffer">DecodeBuffer</a> = <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a> -> <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Char.html#t:Char">Char</a> -> <a href="System-IO.html#t:IO">IO</a> (<a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a>, <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Char.html#t:Char">Char</a>)</li></ul></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:BufferCodec" class="def">BufferCodec</a> from to state <a href="src/GHC-IO-Encoding-Types.html#BufferCodec" class="link">Source</a></p><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:BufferCodec" class="def">BufferCodec</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div class="subs fields"><p class="caption">Fields</p><dl><dt class="src"><a name="v:encode" class="def">encode</a> :: <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> from -> <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> to -> <a href="System-IO.html#t:IO">IO</a> (<a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> from, <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> to)</dt><dd class="doc"><p>The <code>encode</code> function translates elements of the buffer <code>from</code> to the buffer <code>to</code>. It should translate as many elements as possible given the sizes of the buffers, including translating zero elements if there is either not enough room in <code>to</code>, or <code>from</code> does not contain a complete multibyte sequence. </p><p><code>encode</code> should raise an exception if, and only if, <code>from</code> begins with an illegal sequence, or the first element of <code>from</code> is not representable in the encoding of <code>to</code>. That is, if any elements can be successfully translated before an error is encountered, then <code>encode</code> should translate as much as it can and not throw an exception. This behaviour is used by the IO library in order to report translation errors at the point they actually occur, rather than when the buffer is translated. </p></dd><dt class="src"><a name="v:close" class="def">close</a> :: <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></dt><dd class="doc"><p>Resources associated with the encoding may now be released. The <code>encode</code> function may not be called again after calling <code>close</code>. </p></dd><dt class="src"><a name="v:getState" class="def">getState</a> :: <a href="System-IO.html#t:IO">IO</a> state</dt><dd class="doc"><p>Return the current state of the codec. </p><p>Many codecs are not stateful, and in these case the state can be represented as '()'. Other codecs maintain a state. For example, UTF-16 recognises a BOM (byte-order-mark) character at the beginning of the input, and remembers thereafter whether to use big-endian or little-endian mode. In this case, the state of the codec would include two pieces of information: whether we are at the beginning of the stream (the BOM only occurs at the beginning), and if not, whether to use the big or little-endian encoding. </p></dd><dt class="src"><a name="v:setState" class="def">setState</a> :: state -> <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></dt><dd class="doc empty"> </dd></dl><div class="clear"></div></div></td></tr></table></div></div><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:TextEncoding" class="def">TextEncoding</a> <a href="src/GHC-IO-Encoding-Types.html#TextEncoding" class="link">Source</a></p><div class="doc"><p>A <code><a href="GHC-IO-Encoding-Types.html#t:TextEncoding">TextEncoding</a></code> is a specification of a conversion scheme between sequences of bytes and sequences of Unicode characters. </p><p>For example, UTF-8 is an encoding of Unicode characters into a sequence of bytes. The <code><a href="GHC-IO-Encoding-Types.html#t:TextEncoding">TextEncoding</a></code> for UTF-8 is <code>utf8</code>. </p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><span class="keyword">forall</span> dstate estate . <a name="v:TextEncoding" class="def">TextEncoding</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div class="subs fields"><p class="caption">Fields</p><dl><dt class="src"><a name="v:textEncodingName" class="def">textEncodingName</a> :: <a href="Data-Char.html#t:String">String</a></dt><dd class="doc"><p>a string that can be passed to <code>mkTextEncoding</code> to create an equivalent <code><a href="GHC-IO-Encoding-Types.html#t:TextEncoding">TextEncoding</a></code>. </p></dd><dt class="src"><a name="v:mkTextDecoder" class="def">mkTextDecoder</a> :: <a href="System-IO.html#t:IO">IO</a> (<a href="GHC-IO-Encoding-Types.html#t:TextDecoder">TextDecoder</a> dstate)</dt><dd class="doc empty"> </dd><dt class="src"><a name="v:mkTextEncoder" class="def">mkTextEncoder</a> :: <a href="System-IO.html#t:IO">IO</a> (<a href="GHC-IO-Encoding-Types.html#t:TextEncoder">TextEncoder</a> estate)</dt><dd class="doc empty"> </dd></dl><div class="clear"></div></div></td></tr></table></div><div class="subs instances"><p id="control.i:TextEncoding" class="caption collapser" onclick="toggleSection('i:TextEncoding')">Instances</p><div id="section.i:TextEncoding" class="show"><table><tr><td class="src"><a href="Text-Show.html#t:Show">Show</a> <a href="GHC-IO-Encoding-Types.html#t:TextEncoding">TextEncoding</a></td><td class="doc empty"> </td></tr></table></div></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:TextEncoder" class="def">TextEncoder</a> state = <a href="GHC-IO-Encoding-Types.html#t:BufferCodec">BufferCodec</a> <a href="GHC-IO-Buffer.html#t:CharBufElem">CharBufElem</a> <a href="Data-Word.html#t:Word8">Word8</a> state<a href="src/GHC-IO-Encoding-Types.html#TextEncoder" class="link">Source</a></p></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:TextDecoder" class="def">TextDecoder</a> state = <a href="GHC-IO-Encoding-Types.html#t:BufferCodec">BufferCodec</a> <a href="Data-Word.html#t:Word8">Word8</a> <a href="GHC-IO-Buffer.html#t:CharBufElem">CharBufElem</a> state<a href="src/GHC-IO-Encoding-Types.html#TextDecoder" class="link">Source</a></p></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:EncodeBuffer" class="def">EncodeBuffer</a> = <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Char.html#t:Char">Char</a> -> <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a> -> <a href="System-IO.html#t:IO">IO</a> (<a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Char.html#t:Char">Char</a>, <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a>)<a href="src/GHC-IO-Encoding-Types.html#EncodeBuffer" class="link">Source</a></p></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:DecodeBuffer" class="def">DecodeBuffer</a> = <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a> -> <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Char.html#t:Char">Char</a> -> <a href="System-IO.html#t:IO">IO</a> (<a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Word.html#t:Word8">Word8</a>, <a href="GHC-IO-Buffer.html#t:Buffer">Buffer</a> <a href="Data-Char.html#t:Char">Char</a>)<a href="src/GHC-IO-Encoding-Types.html#DecodeBuffer" class="link">Source</a></p></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.9.2</p></div></body></html>