| Copyright | (c) The University of Glasgow 2008-2009 |
|---|---|
| License | see libraries/base/LICENSE |
| Maintainer | libraries@haskell.org |
| Stability | internal |
| Portability | non-portable |
| Safe Haskell | Trustworthy |
| Language | Haskell2010 |
GHC.IO.Encoding
Description
Text codecs for I/O
dataBufferCodec from to stateSource#
Constructors
| BufferCodec | |
Fields
| |
ATextEncoding is a specification of a conversion scheme between sequences of bytes and sequences of Unicode characters.
For example, UTF-8 is an encoding of Unicode characters into a sequence of bytes. TheTextEncoding for UTF-8 isutf8.
Constructors
| TextEncoding | |
Fields
| |
| ShowTextEncodingSource# | Since: 4.3.0.0 |
Instance detailsDefined inGHC.IO.Encoding.Types | |
typeTextEncoder state =BufferCodecCharBufElemWord8 stateSource#
typeTextDecoder state =BufferCodecWord8CharBufElem stateSource#
Since: 4.4.0.0
Constructors
| InputUnderflow | Stopped because the input contains insufficient available elements, or all of the input sequence has been successfully translated. |
| OutputUnderflow | Stopped because the output contains insufficient free elements |
| InvalidSequence | Stopped because there are sufficient free elements in the output to output at least one encoded ASCII character, but the input contains an invalid or unrepresentable sequence |
| EqCodingProgressSource# | Since: 4.4.0.0 |
Instance detailsDefined inGHC.IO.Encoding.Types | |
| ShowCodingProgressSource# | Since: 4.4.0.0 |
Instance detailsDefined inGHC.IO.Encoding.Types | |
The Latin1 (ISO8859-1) encoding. This encoding maps bytes directly to the first 256 Unicode code points, and is thus not a complete Unicode encoding. An attempt to write a character greater than '\255' to aHandle using thelatin1 encoding will result in an error.
The UTF-8 Unicode encoding
utf8_bom ::TextEncodingSource#
The UTF-8 Unicode encoding, with a byte-order-mark (BOM; the byte sequence 0xEF 0xBB 0xBF). This encoding behaves likeutf8, except that on input, the BOM sequence is ignored at the beginning of the stream, and on output, the BOM sequence is prepended.
The byte-order-mark is strictly unnecessary in UTF-8, but is sometimes used to identify the encoding of a file.
The UTF-16 Unicode encoding (a byte-order-mark should be used to indicate endianness).
The UTF-16 Unicode encoding (litte-endian)
The UTF-16 Unicode encoding (big-endian)
The UTF-32 Unicode encoding (a byte-order-mark should be used to indicate endianness).
The UTF-32 Unicode encoding (litte-endian)
The UTF-32 Unicode encoding (big-endian)
initLocaleEncoding ::TextEncodingSource#
Since: 4.5.0.0
getLocaleEncoding ::IOTextEncodingSource#
The Unicode encoding of the current locale
Since: 4.5.0.0
getFileSystemEncoding ::IOTextEncodingSource#
The Unicode encoding of the current locale, but allowing arbitrary undecodable bytes to be round-tripped through it.
ThisTextEncoding is used to decode and encode command line arguments and environment variables on non-Windows platforms.
On Windows, this encoding *should not* be used if possible because the use of code pages is deprecated: Strings should be retrieved via the "wide" W-family of UTF-16 APIs instead
Since: 4.5.0.0
getForeignEncoding ::IOTextEncodingSource#
The Unicode encoding of the current locale, but where undecodable bytes are replaced with their closest visual match. Used for theCString marshalling functions inForeign.C.String
Since: 4.5.0.0
setLocaleEncoding ::TextEncoding ->IO ()Source#
Since: 4.5.0.0
setFileSystemEncoding ::TextEncoding ->IO ()Source#
Since: 4.5.0.0
setForeignEncoding ::TextEncoding ->IO ()Source#
Since: 4.5.0.0
An encoding in which Unicode code points are translated to bytes by taking the code point modulo 256. When decoding, bytes are translated directly into the equivalent code point.
This encoding never fails in either direction. However, encoding discards information, so encode followed by decode is not the identity.
Since: 4.4.0.0
mkTextEncoding ::String ->IOTextEncodingSource#
Look up the named Unicode encoding. May fail with
isDoesNotExistError if the encoding is unknownThe set of known encodings is system-dependent, but includes at least:
UTF-8
UTF-16,UTF-16BE,UTF-16LEUTF-32,UTF-32BE,UTF-32LEThere is additional notation (borrowed from GNU iconv) for specifying how illegal characters are handled:
//IGNORE, e.g.UTF-8//IGNORE, will cause all illegal sequences on input to be ignored, and on output will drop all code points that have no representation in the target encoding.//TRANSLIT will choose a replacement character for illegal sequences or code points.//ROUNDTRIP will use a PEP383-style escape mechanism to represent any invalid bytes in the input as Unicode codepoints (specifically, as lone surrogates, which are normally invalid in UTF-32). Upon output, these special codepoints are detected and turned back into the corresponding original byte.In theory, this mechanism allows arbitrary data to be roundtripped via aString with no loss of data. In practice, there are two limitations to be aware of:
On Windows, you can access supported code pages with the prefixCP; for example,"CP1250".
argvEncoding ::IOTextEncodingSource#
Internal encoding of argv
Produced byHaddock version 2.20.0