Skip converting to 16 bits charsets

pull/187/head
M66B 4 years ago
parent d49deb9f42
commit 09b771bd03

@ -124,6 +124,12 @@ public class MessageHelper {
private static final int FORMAT_FLOWED_LINE_LENGTH = 72;
private static final long MIN_REQUIRED_SPACE = 250 * 1024L * 1024L;
private static final List<Charset> CHARSET16 = Collections.unmodifiableList(Arrays.asList(
StandardCharsets.UTF_16,
StandardCharsets.UTF_16BE,
StandardCharsets.UTF_16LE
));
// https://tools.ietf.org/html/rfc4021
static void setSystemProperties(Context context) {
@ -1793,13 +1799,13 @@ public class MessageHelper {
if (!TextUtils.isEmpty(charset))
try {
Charset detected = CharsetHelper.detect(result);
Log.i("Charset detected=" + detected + " meta=" + meta);
Log.i("Charset meta=" + meta);
Charset c = Charset.forName(charset);
if (c.equals(StandardCharsets.UTF_8) && !CharsetHelper.isUTF8(result))
break;
if (c.equals(StandardCharsets.UTF_16) && !c.equals(detected))
if (CHARSET16.contains(c))
break;
Log.e("Converting meta=" + c);
result = new String(result.getBytes(StandardCharsets.ISO_8859_1), c);
break;
} catch (Throwable ex) {

Loading…
Cancel
Save