Skip converting to 16 bits charsets

pull/187/head
M66B 5 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 int FORMAT_FLOWED_LINE_LENGTH = 72;
private static final long MIN_REQUIRED_SPACE = 250 * 1024L * 1024L; 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 // https://tools.ietf.org/html/rfc4021
static void setSystemProperties(Context context) { static void setSystemProperties(Context context) {
@ -1793,13 +1799,13 @@ public class MessageHelper {
if (!TextUtils.isEmpty(charset)) if (!TextUtils.isEmpty(charset))
try { try {
Charset detected = CharsetHelper.detect(result); Log.i("Charset meta=" + meta);
Log.i("Charset detected=" + detected + " meta=" + meta);
Charset c = Charset.forName(charset); Charset c = Charset.forName(charset);
if (c.equals(StandardCharsets.UTF_8) && !CharsetHelper.isUTF8(result)) if (c.equals(StandardCharsets.UTF_8) && !CharsetHelper.isUTF8(result))
break; break;
if (c.equals(StandardCharsets.UTF_16) && !c.equals(detected)) if (CHARSET16.contains(c))
break; break;
Log.e("Converting meta=" + c);
result = new String(result.getBytes(StandardCharsets.ISO_8859_1), c); result = new String(result.getBytes(StandardCharsets.ISO_8859_1), c);
break; break;
} catch (Throwable ex) { } catch (Throwable ex) {

Loading…
Cancel
Save