解码UTF8电子邮件标题 [英] Decode an UTF8 email header
问题描述
我有一个电子邮件主题:
I have an email subject of the form:
=?utf-8?B?T3.....?=
电子邮件的正文是utf-8 base64编码 - 已经解码了。
我目前使用Perl的Email :: MIME模块解码电子邮件。
The body of the email is utf-8 base64 encoded - and has decoded fine. I am current using Perl's Email::MIME module to decode the email.
=?utf-8分隔符的含义是什么?从这个字符串中提取信息?
What is the meaning of the =?utf-8 delimiter and how do I extract information from this string?
推荐答案
encoded-word
令牌(根据 RFC 2047 )可能发生在某些标题的值中。他们被解析如下:
The encoded-word
tokens (as per RFC 2047) can occur in values of some headers. They are parsed as follows:
=?<charset>?<encoding>?<data>?=
在这种情况下,字符集是UTF-8,编码是 B
这意味着base64(另一个选项是 Q
,这意味着Quoted Printable)。
Charset is UTF-8 in this case, the encoding is B
which means base64 (the other option is Q
which means Quoted Printable).
要阅读它,首先对base64进行解码,然后将其视为UTF-8字符。
To read it, first decode the base64, then treat it as UTF-8 characters.
还可以阅读各种Internet Mail RFC了解更多详细信息,主要是< a href =http://www.faqs.org/rfcs/rfc2047.html =noreferrer> RFC 2047 。
Also read the various Internet Mail RFCs for more detail, mainly RFC 2047.
既然你正在使用Perl, Encode :: MIME :: Header 可能会使用:
Since you are using Perl, Encode::MIME::Header could be of use:
概要
SYNOPSIS
use Encode qw/encode decode/;
$utf8 = decode('MIME-Header', $header);
$header = encode('MIME-Header', $utf8);
摘要
此模块实现RFC 2047 Mime
标题编码。有3个变量
编码名称; MIME-Header,MIME-B
和MIME-Q。差异是
描述如下
This module implements RFC 2047 Mime Header Encoding. There are 3 variant encoding names; MIME-Header, MIME-B and MIME-Q. The difference is described below
decode() encode()
MIME-Header Both B and Q =?UTF-8?B?....?=
MIME-B B only; Q croaks =?UTF-8?B?....?=
MIME-Q Q only; B croaks =?UTF-8?Q?....?=
这篇关于解码UTF8电子邮件标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!