I have the following header:
From: =?iso-8859-1?Q?Marta_Falc=E3o?= <marta.falcao@example.com.br>
I can easily split out the stuff before the <
, which leaves me with
"=?iso-8859-1?Q?Marta_Falc=E3o?="
What can I use to turn this into "Marta Falcão"
?
Using the newer Mail gem:
Mail::Encodings.value_decode(str)
orMail::Encodings.unquote_and_convert_to(str, to_encoding)
Thanks to Roland Illig for his comment, which led me to two options:
Rfc2047.decode(header)
TMail::Unquoter.unquote_and_convert_to(header, 'utf-8')
or better yetTMail::Address.parse(header).friendly
, the latter of which strips out the<email address>
part