diff options
author | Simon Marlow <marlowsd@gmail.com> | 2009-07-15 12:22:57 +0000 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2009-07-15 12:22:57 +0000 |
commit | ecfac87dcc64e7f034f24fe23a873fc8f1f7d9b6 (patch) | |
tree | 559488cf46b63a71b4752e9eaf94e2f02605b5b6 /libraries/base/GHC/IO/Encoding.hs | |
parent | 6bc00b292d2de418b87de44ffb9ad00541b80b43 (diff) | |
download | haskell-ecfac87dcc64e7f034f24fe23a873fc8f1f7d9b6.tar.gz |
Add the utf8_bom codec
as suggested during the discussion on the libraries list.
Diffstat (limited to 'libraries/base/GHC/IO/Encoding.hs')
-rw-r--r-- | libraries/base/GHC/IO/Encoding.hs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/libraries/base/GHC/IO/Encoding.hs b/libraries/base/GHC/IO/Encoding.hs index 78aad98af1..a1da1b1b21 100644 --- a/libraries/base/GHC/IO/Encoding.hs +++ b/libraries/base/GHC/IO/Encoding.hs @@ -16,7 +16,7 @@ module GHC.IO.Encoding ( BufferCodec(..), TextEncoding(..), TextEncoder, TextDecoder, latin1, latin1_encode, latin1_decode, - utf8, + utf8, utf8_bom, utf16, utf16le, utf16be, utf32, utf32le, utf32be, localeEncoding, @@ -54,6 +54,17 @@ latin1 = Latin1.latin1_checked utf8 :: TextEncoding utf8 = UTF8.utf8 +-- | The UTF-8 Unicode encoding, with a byte-order-mark (BOM; the byte +-- sequence 0xEF 0xBB 0xBF). This encoding behaves like 'utf8', +-- 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. +-- +utf8_bom :: TextEncoding +utf8_bom = UTF8.utf8_bom + -- | The UTF-16 Unicode encoding (a byte-order-mark should be used to -- indicate endianness). utf16 :: TextEncoding |