iconv

String encoding conversion

Version on this page:0.4.1.3
LTS Haskell 22.13:0.4.1.3@rev:1
Stackage Nightly 2024-03-14:0.4.1.3@rev:1
Latest on Hackage:0.4.1.3@rev:1

See all snapshots iconv appears in

BSD-3-Clause licensed and maintained by Duncan Coutts
This version can be pinned in stack with:iconv-0.4.1.3@sha256:4f0b2f09bb8c33199e3c3fdfcd35e576d17cbf5188b18f404ffdfa68a8ccc40e,1192

Module documentation for 0.4.1.3

Depends on 2 packages(full list with versions):
Used by 2 packages in nightly-2017-10-28(full list with versions):

Codec.Text.IConv

This is a Haskell binding to the iconv() C library function.

The only module exported is Codec.Text.IConv, which provides a single function:

-- | Convert fromCharset toCharset input output
convert :: EncodingName -> EncodingName -> Lazy.ByteString -> Lazy.ByteString

where fromCharset and toCharset are the names of the input and output character set encodings, and input and output are the input and output text as lazy ByteStrings. For example:

 import qualified Codec.Text.IConv as IConv
 import qualified Data.ByteString.Lazy as BS
 
 main = do
   -- read UTF8, but convert to UTF32 internally
   content <- fmap (IConv.convert "UTF-8" "UTF-32") (BS.readFile file)
   ...

An example program, similar to the iconv program, is included.

Character set encodings

To see a list of encoding names which are known by your operating system, run iconv --list in a shell. Likely encodings are listed on the libiconv web site.

Availability of iconv()

The iconv(3) function conforms to POSIX.1-2001. It is provided by the GNU C library.

On systems which do not have a native iconv() implementation you may need to install libiconv.

Changes

0.4.1.3 Duncan Coutts [email protected] June 2015

  • Fixed building with GHC 7.10

0.4.1.2 Duncan Coutts [email protected] December 2013

  • Fixed building with GHC 7.8

0.4.1.1 Duncan Coutts [email protected] October 2012

  • Fixed building with bytestring 0.10