mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 19:52:17 -05:00
Code cleanup
This commit is contained in:
parent
c5802ed8ef
commit
4b42d0e062
@ -905,15 +905,16 @@ public class MimeUtility {
|
|||||||
{"image/pjpeg", "image/jpeg"}, // see issue 1712
|
{"image/pjpeg", "image/jpeg"}, // see issue 1712
|
||||||
{"application/x-zip-compressed", "application/zip"} // see issue 3791
|
{"application/x-zip-compressed", "application/zip"} // see issue 3791
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Table for charset fallback.
|
* Table for character set fall-back.
|
||||||
*
|
*
|
||||||
* Table format: not supported charset (regex), fallback
|
* Table format: unsupported charset (regular expression), fall-back charset
|
||||||
*/
|
*/
|
||||||
private static final String[][] CHARSET_FALLBACK_MAP = new String[][] {
|
private static final String[][] CHARSET_FALLBACK_MAP = new String[][] {
|
||||||
{"iso-2022-jp-[\\d]+", "iso-2022-jp"},
|
{"iso-2022-jp-[\\d]+", "iso-2022-jp"},
|
||||||
{".*", "US-ASCII"}
|
// Default fall-back is US-ASCII
|
||||||
|
{".*", "US-ASCII"}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static String unfold(String s) {
|
public static String unfold(String s) {
|
||||||
@ -2301,7 +2302,7 @@ public class MimeUtility {
|
|||||||
|
|
||||||
charset = "shift_jis";
|
charset = "shift_jis";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 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.
|
||||||
* this function may also throw an exception if the charset name is not known
|
* this function may also throw an exception if the charset name is not known
|
||||||
@ -2312,20 +2313,24 @@ public class MimeUtility {
|
|||||||
} catch (IllegalCharsetNameException e) {
|
} catch (IllegalCharsetNameException e) {
|
||||||
supported = false;
|
supported = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String[] rule: CHARSET_FALLBACK_MAP) {
|
for (String[] rule: CHARSET_FALLBACK_MAP) {
|
||||||
if (supported)
|
if (supported) {
|
||||||
break;
|
break;
|
||||||
if (charset.matches(rule[0])) {
|
}
|
||||||
|
|
||||||
|
if (charset.matches(rule[0])) {
|
||||||
Log.e(K9.LOG_TAG, "I don't know how to deal with the charset " + charset +
|
Log.e(K9.LOG_TAG, "I don't know how to deal with the charset " + charset +
|
||||||
". Falling back to " + rule[1]);
|
". Falling back to " + rule[1]);
|
||||||
charset = rule[1];
|
charset = rule[1];
|
||||||
try {
|
try {
|
||||||
supported = Charset.isSupported(charset);
|
supported = Charset.isSupported(charset);
|
||||||
} catch (IllegalCharsetNameException e) {
|
} catch (IllegalCharsetNameException e) {
|
||||||
supported = false;
|
supported = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert and return as new String
|
* Convert and return as new String
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user