I have a string in this form: =?utf-8?B?zr...
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?
MimeUtility.decodeText is working for me,
eg,
MimeUtility.decodeText("=?UTF-8?B?4K6q4K+N4K6q4K+K4K604K6/4K614K+BIQ==?=");
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.
You can grab it from maven with
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.4</version>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With