解码UTF-8电子邮件主题? [英] Decoding UTF-8 email subject?
问题描述
我有一个这样的字符串: =?utf-8?B?zr ...
I have a string in this form: =?utf-8?B?zr...
而且我想以适当的UTF-8编码获取文件的名称。在maven中央有一个库方法,会为我做这个解码,还是需要手动测试模式和解码base64?
And I want to get the name of the file in proper UTF-8 encoding. Is there a library method somewhere in maven central that will do this decoding for me, or will I need to test the pattern and decode base64 manually?
推荐答案
在MIME术语中,这些编码的块被称为编码字。查看 JavaMail中的javax.mail.internet.MimeUtility.decodeText
。 decodeText
方法将解码字符串中的所有编码字。
In MIME terminology, those encoded chunks are called encoded-words. Check out javax.mail.internet.MimeUtility.decodeText
in JavaMail. The decodeText
method will decode all the encoded-words in a string.
您可以从maven中获取
You can grab it from maven with
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.4</version>
这篇关于解码UTF-8电子邮件主题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!