From d78e7a0d6949f02b7d774f8addd86e74b0bc9a27 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Mon, 2 Aug 2010 01:27:46 +0000 Subject: [PATCH] Switch from the incomplete (but compatible with java 1.3) mime4j charset alias resolver to the core java nio version with a better charset database; rather than falling back to not showing the user a failing message, fall back to showing the user the message as ascii -- it makes it possible to get _something_ out of an unknown-charset message, rather than just a "ha ha. no." error. --- src/com/fsck/k9/mail/internet/MimeUtility.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/com/fsck/k9/mail/internet/MimeUtility.java b/src/com/fsck/k9/mail/internet/MimeUtility.java index f8472d544..3448b3fce 100644 --- a/src/com/fsck/k9/mail/internet/MimeUtility.java +++ b/src/com/fsck/k9/mail/internet/MimeUtility.java @@ -9,7 +9,6 @@ import org.apache.commons.io.IOUtils; import org.apache.james.mime4j.decoder.Base64InputStream; import org.apache.james.mime4j.decoder.DecoderUtil; import org.apache.james.mime4j.decoder.QuotedPrintableInputStream; -import org.apache.james.mime4j.util.CharsetUtil; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -17,6 +16,8 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.regex.Pattern; +import java.nio.charset.Charset; + public class MimeUtility { @@ -373,11 +374,12 @@ public class MimeUtility /* * See if there is conversion from the MIME charset to the Java one. */ - charset = CharsetUtil.toJavaCharset(originalCharset); + charset = Charset.forName(originalCharset).name(); if (charset == null) { - return String.format(K9.app.getString(R.string.charset_not_found), originalCharset); + Log.e(K9.LOG_TAG,"I don't know how to deal with the charset "+originalCharset+". Falling back to US-ASCII"); + charset = "US-ASCII"; } }