mirror of
https://github.com/moparisthebest/k-9
synced 2025-03-02 17:41:57 -05:00
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.
This commit is contained in:
parent
7fc921c0b7
commit
d78e7a0d69
@ -9,7 +9,6 @@ import org.apache.commons.io.IOUtils;
|
|||||||
import org.apache.james.mime4j.decoder.Base64InputStream;
|
import org.apache.james.mime4j.decoder.Base64InputStream;
|
||||||
import org.apache.james.mime4j.decoder.DecoderUtil;
|
import org.apache.james.mime4j.decoder.DecoderUtil;
|
||||||
import org.apache.james.mime4j.decoder.QuotedPrintableInputStream;
|
import org.apache.james.mime4j.decoder.QuotedPrintableInputStream;
|
||||||
import org.apache.james.mime4j.util.CharsetUtil;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -17,6 +16,8 @@ import java.io.InputStream;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
|
|
||||||
public class MimeUtility
|
public class MimeUtility
|
||||||
{
|
{
|
||||||
@ -373,11 +374,12 @@ public class MimeUtility
|
|||||||
/*
|
/*
|
||||||
* See if there is conversion from the MIME charset to the Java one.
|
* 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)
|
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";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user