将 7 位文本转换为纯文本 perl
我解析电子邮件消息,发现编码部分:7bit 如何将这部分的文本转换为纯文本? 我用 Perl
I parsing email message and i found part with encoding: 7bit
how a can convert text of this part to plain text?
i use perl
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
意味着文本已经是纯旧的 ASCII 文本。无需转换。 (好吧,除非
Content-Type
标头指示基于非 ASCII 的字符集,但这种情况非常罕见,尤其是对于 7 位文本。)means that the text is already plain old ASCII text. No conversion is necessary. (Well, unless the
Content-Type
header indicates a non-ASCII-based charset, but those are pretty rare, especially with 7bit text.)听起来您有 UU 编码 数据(旧方法)或 MIME 编码。要解决这个问题,您可以使用 Convert::UU 和 MIME::Base64 CPAN 模块。
要使用 MIME::Base64(或其纯 Perl 实现,MIME::Base64::Perl):
你怎么知道其中的区别?
现代 MIME 编码的文本看起来像这样(特别注意
MIME-Version:
标头告诉您它是 MIME 编码的,Content-Transfer-Encoding
标头告诉您编码基础 - 如果它不是 base64,您需要一个不同的 CPAN 模块:UU 编码文本看起来像这样:
如果编码数据看起来与上述示例不同,请发布确切的格式,以便我们确定它是什么。
It sounds like you have UU-encoded data (older method) or MIME-encoded. To deal with that, you can use Convert::UU and MIME::Base64 CPAN modules respectively.
To use MIME::Base64 (or its pure-Perl implementation, MIME::Base64::Perl):
How do you know the difference?
The modern MIME encoded text looks like this (Especially pay attention to
MIME-Version:
header which tells you it's MIME-encoded as well asContent-Transfer-Encoding
header which tells you the encoding base - if it's not base64, you need a different CPAN module:UU-encoded text would look something like:
If the encoded data looks differently than either of the above samples, please post the exact format so we can determine what it is.