我有很多来自不同来源的电子邮件。
它们都有附件,其中很多附件名称都是中文的,所以这些
名称由电子邮件客户端转换为 Base64。
当我收到这些电子邮件时,我希望解码该名称。但还有其他名称
不是base64。如何使用以下命令区分字符串是否为 base64jython编程语言?
Ie.
第一个附件:
------=_NextPart_000_0091_01C940CC.EF5AC860
Content-Type: application/vnd.ms-excel;
name="Copy of Book1.xls"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="Copy of Book1.xls"
第二个附件:
------=_NextPart_000_0091_01C940CC.EF5AC860
Content-Type: application/vnd.ms-excel;
name="=?gb2312?B?uLGxvmhlbrixsb5nLnhscw==?="
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="=?gb2312?B?uLGxvmhlbrixsb5nLnhscw==?="
请同时注意“内容传输编码“有base64
标头值告诉您:
=?gb2312?B?uLGxvmhlbrixsb5nLnhscw==?=
"=?" introduces an encoded value
"gb2312" denotes the character encoding of the original value
"B" denotes that B-encoding (equal to Base64) was used (the alternative
is "Q", which refers to something close to quoted-printable)
"?" functions as a separator
"uLG..." is the actual value, encoded using the encoding specified before
"?=" ends the encoded value
所以分裂“?”实际上得到了这个(JSON 表示法)
["=", "gb2312", "B", "uLGxvmhlbrixsb5nLnhscw==", "="]
在结果数组中,如果“B”位于位置 2 上,则您将在位置 3 上看到一个 Base-64 编码的字符串。解码后,请务必注意位置 1 上的编码,可能最好进行转换使用该信息将整个内容转换为 UTF-8。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)