请注意,这个问题与this https://stackoverflow.com/questions/15098452/how-can-i-decode-a-quotedprintable-encoded-string以前未回答的问题。
它也同样是这个 PHP 问题 https://stackoverflow.com/questions/3468849/iso-8859-1-in-mail-subject,但我正在寻找 haskell 的等效项。
RFC 2047 https://www.rfc-editor.org/rfc/rfc2047定义“编码字”编码的标准并提供以下示例:
=?iso-8859-1?q?this=20is=20some=20text?=
是否有一个标准的 haskell 库来处理将其解码为正确的Text
表示?
使用 parsec 和 RFC 规范编写自定义解析器应该不会太难,但这似乎是其他语言中常见的已解决问题,我找不到 Haskell 等效项,而且我不想重新发明轮子在这里。
In the mime https://hackage.haskell.org/package/mime包看看decodeWord https://hackage.haskell.org/package/mime-0.4.0.2/docs/src/Codec-MIME-Decode.html#decodeWord在模块中Codec.MIME.Decode https://hackage.haskell.org/package/mime-0.4.0.2/docs/Codec-MIME-Decode.html:
ghci> import Codec.MIME.Decode
ghci> decodeWord "=?iso-8859-1?q?this=20is=20some=20text?="
Just ("this is some text","")
从阅读源代码来看iso-8859-1
and us-ascii
都支持。
还有decodeWords
它使用decodeWord
翻译整个字符串的函数:
ghci> decodeWords "Foo=?iso-8859-1?q?this=20is=20some=20text?=Bar"
"Foothis is some textBar"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)