How can I decode a string with a coded word?

Please note that this question is the same as this one that did not answer the question earlier.
It is also the same as this PHP question , but I am looking for the haskell equivalent.

RFC 2047 defines the "coded word" coding standard and provides an example:

=?iso-8859-1?q?this=20is=20some=20text?=

Is there a standard haskell library for working with decoding this into the correct representation Text?

It doesn't have to be too complicated to write a custom analyzer using parsec and RFC Spec, but it seems like a normal, resolved problem in other languages ​​that I cannot find the Haskell equivalent to, and I would prefer not to repeat - enter the wheel here.

+1
source share
1 answer

In the package, mimeview decodeWordin the module Codec.MIME.Decode:

ghci> import Codec.MIME.Decode
ghci> decodeWord "=?iso-8859-1?q?this=20is=20some=20text?="
Just ("this is some text","")

From reading source code iso-8859-1, both and us-ascii.

There is also decodeWordsone that uses a function decodeWordto translate the entire line:

ghci> decodeWords "Foo=?iso-8859-1?q?this=20is=20some=20text?=Bar"
"Foothis is some textBar"
+2
source

All Articles