本文介绍了如何在Ruby中解码RFC 2047编码的电子邮件标头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下标头:

From: =?iso-8859-1?Q?Marta_Falc=E3o?= <[email protected]>

我可以很容易地在< ,这给我留下了

I can easily split out the stuff before the <, which leaves me with

"=?iso-8859-1?Q?Marta_Falc=E3o?="

我可以用来将其转换为 MartaFalcão

What can I use to turn this into "Marta Falcão"?

推荐答案

感谢的评论,使我有两个选择:

Thanks to Roland Illig for his comment, which led me to two options:


  1. install 并调用 Rfc2047.decode(header)

  2. 安装并致电 TMail :: Unquoter .unquote_and_convert_to(header,'utf-8')或更好的 TMail :: Address.parse(header).friendly ,后者删除<电子邮件地址> 部分

  1. install rfc2047-ruby and call Rfc2047.decode(header)
  2. install TMail and call TMail::Unquoter.unquote_and_convert_to(header, 'utf-8') or better yet TMail::Address.parse(header).friendly, the latter of which strips out the <email address> part

这篇关于如何在Ruby中解码RFC 2047编码的电子邮件标头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 02:05