[Haskell-cafe] ANNOUNCE: dataenc-0.10.1

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Wed Dec 12 17:41:35 EST 2007


On Wed, 2007-12-12 at 13:30 +0000, Magnus Therning wrote:

> The visible change is the addition of a function, decode', that allows
> lazier decoding  by shifting some responisility to the user.

That's interesting. It's in the same spirit as the lazy variant provided
in the iconv lib. It'll be interesting to see if this is the best
general interface for allowing people to lazily convert and handle
conversion errors.

The slight difference is that the iconv lib works over bytestring chunks
rather than individual Word8 and provides a bit more detail about
errors. It's otherwise pretty similar.

convertLazily
:: EncodingName
  -- ^ Name of input string encoding
-> EncodingName
  -- ^ Name of output string
encoding
-> ByteString
  -- ^ Input text
-> [Span]
  -- ^ Output text spans

When nothing goes wrong we expect just a bunch of Spans. If there are
conversion errors we get other span types.

data Span = Span ByteString | ConversionError ConversionError

data ConversionError =
       UnsuportedConversion EncodingName EncodingName
     | InvalidChar Offset
     | IncompleteChar Offset
     | UnexpectedError Errno

http://hackage.haskell.org/packages/archive/iconv/0.4/doc/html/Codec-Text-IConv.html#v%3AconvertLazily

Duncan



More information about the Haskell-Cafe mailing list