mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-23 18:02:15 -05:00
Switch from using the mime4j charset list to the Java 1.5 java.nio.charset Charset class.
Based on this comment in MIME4J, this seems like a win: * Utility class for working with character sets. It is somewhat similar to * the Java 1.4 <code>java.nio.charset.Charset</code> class but knows many * more aliases and is compatible with Java 1.3. It will use a simple detection * mechanism to detect what character sets the current VM supports. This will * be a sub-set of the character sets listed in the * <a href="http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html"> * Java 1.5 (J2SE5.0) Supported Encodings</a> document. * <p> * The <a href="http://www.iana.org/assignments/character-sets"> * IANA Character Sets</a> document has been used to determine the preferred * MIME character set names and to get a list of known aliases. * <p>
This commit is contained in:
parent
27a0efcf1d
commit
8bd2f9c260
@ -6,12 +6,14 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
|
||||
|
||||
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 android.util.Log;
|
||||
|
||||
@ -24,6 +26,8 @@ import com.fsck.k9.mail.Multipart;
|
||||
import com.fsck.k9.mail.Part;
|
||||
|
||||
public class MimeUtility {
|
||||
|
||||
|
||||
public static String unfold(String s) {
|
||||
if (s == null) {
|
||||
return null;
|
||||
@ -129,6 +133,8 @@ public class MimeUtility {
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String getTextFromPart(Part part) {
|
||||
Charset mCharsetConverter;
|
||||
|
||||
try {
|
||||
if (part != null && part.getBody() != null) {
|
||||
InputStream in = part.getBody().getInputStream();
|
||||
@ -153,7 +159,8 @@ public class MimeUtility {
|
||||
/*
|
||||
* See if there is conversion from the MIME charset to the Java one.
|
||||
*/
|
||||
charset = CharsetUtil.toJavaCharset(charset);
|
||||
mCharsetConverter = Charset.forName(charset);
|
||||
charset = mCharsetConverter.name();
|
||||
}
|
||||
if (charset != null) {
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user