Javamail ISO-8859-1格式化 [英] Javamail ISO-8859-1 formatting
问题描述
地址[] froma = m。从获得();
String from = InternetAddress.toString(froma);
地址[] toa = m.getRecipients(Message.RecipientType.TO);
String to = InternetAddress.toString(toa);
我得到一个这样的字符串:
Georg =?ISO-8859-1?Q?SP = E4the?=
,它必须是GeorgSpäthe或Georg Spaethe。
I认为问题是这是德语邮件的另一个编码,有人可以帮我解决这个问题吗?
根据 RFC 2047 编码,因此您需要先解码它们。
String decoding = MimeUtility.decodeText(Georg =?ISO-8859-1?Q?SP = E4the?=);
JDK导入:
import javax.mail.internet.MimeUtility;
对于Android:
import com.android.email.mail.internet;
另请参阅 MimeUtili的Javadoc ty
I made an E- Mail Client for my Android phone with the Javamail Api. If I try to get the sender's mail address and the recipients mail address with the following methods:
Address[] froma = m.getFrom();
String from = InternetAddress.toString(froma);
Address[] toa = m.getRecipients(Message.RecipientType.TO);
String to = InternetAddress.toString(toa);
I get a String like this back:
"Georg =?ISO-8859-1?Q?SP=E4the?= and it has to be Georg Späthe or Georg Spaethe.
I think the Problem is that this are German Mails with another encoding. Can anybody help me to solve that problem?
MIME headers are encoded as per RFC 2047, therefore you need to decode them first.
String decoded = MimeUtility.decodeText("Georg =?ISO-8859-1?Q?SP=E4the?=");
JDK import:
import javax.mail.internet.MimeUtility;
For Android:
import com.android.email.mail.internet;
See also Javadoc of MimeUtility
这篇关于Javamail ISO-8859-1格式化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!