1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-15 14:05:05 -05:00

Code cleanup

This commit is contained in:
cketti 2013-03-10 09:39:03 +01:00
parent c5802ed8ef
commit 4b42d0e062

View File

@ -907,13 +907,14 @@ public class MimeUtility {
};
/**
* 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[][] {
{"iso-2022-jp-[\\d]+", "iso-2022-jp"},
{".*", "US-ASCII"}
{"iso-2022-jp-[\\d]+", "iso-2022-jp"},
// Default fall-back is US-ASCII
{".*", "US-ASCII"}
};
public static String unfold(String s) {
@ -2312,20 +2313,24 @@ public class MimeUtility {
} catch (IllegalCharsetNameException e) {
supported = false;
}
for (String[] rule: CHARSET_FALLBACK_MAP) {
if (supported)
break;
if (charset.matches(rule[0])) {
if (supported) {
break;
}
if (charset.matches(rule[0])) {
Log.e(K9.LOG_TAG, "I don't know how to deal with the charset " + charset +
". Falling back to " + rule[1]);
charset = rule[1];
try {
supported = Charset.isSupported(charset);
} catch (IllegalCharsetNameException e) {
supported = false;
}
}
charset = rule[1];
try {
supported = Charset.isSupported(charset);
} catch (IllegalCharsetNameException e) {
supported = false;
}
}
}
/*
* Convert and return as new String
*/