iconv: String encoding conversion

[ bsd3, library, text ] [ Propose Tags ] [ Report a vulnerability ]

Provides an interface to the POSIX iconv library functions for string encoding conversion.


[Skip to Readme]

Modules

[Index]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.2, 0.4, 0.4.0.2, 0.4.1.0, 0.4.1.1, 0.4.1.2, 0.4.1.3
Change log changelog.md
Dependencies base (>=3 && <5), bytestring (>=0.9 && <0.13) [details]
License BSD-3-Clause
Copyright (c) 2006-20015 Duncan Coutts
Author Duncan Coutts <duncan@community.haskell.org>
Maintainer Duncan Coutts <duncan@community.haskell.org>
Revised Revision 1 made by Bodigrim at 2023-08-07T20:05:22Z
Category Text
Source repo head: darcs get http://code.haskell.org/iconv/
Uploaded by DuncanCoutts at 2015-06-01T09:22:17Z
Distributions Debian:0.4.1.3, LTSHaskell:0.4.1.3, NixOS:0.4.1.3, Stackage:0.4.1.3
Reverse Dependencies 11 direct, 9 indirect [details]
Downloads 11987 total (41 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2015-06-03 [all 1 reports]

Readme for iconv-0.4.1.3

[back to package description]

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.