Workaround incorrect UTF-16 meta

pull/187/head
M66B 5 years ago
parent f48821fceb
commit 0f811d2c72

@ -1793,11 +1793,14 @@ public class MessageHelper {
if (!TextUtils.isEmpty(charset)) if (!TextUtils.isEmpty(charset))
try { try {
Log.i("Charset=" + meta); Charset detected = CharsetHelper.detect(result);
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;
result = new String(result.getBytes(StandardCharsets.ISO_8859_1), charset); if (c.equals(StandardCharsets.UTF_16) && !c.equals(detected))
break;
result = new String(result.getBytes(StandardCharsets.ISO_8859_1), c);
break; break;
} catch (Throwable ex) { } catch (Throwable ex) {
Log.w(ex); Log.w(ex);

Loading…
Cancel
Save