diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index c9dad76f24..629f09235c 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -1884,21 +1884,22 @@ public class MessageHelper { } if (h.isPlainText()) { - if (StandardCharsets.ISO_8859_1.equals(cs) && CharsetHelper.isUTF8(result)) { - Log.i("Charset upgrade=UTF8"); - result = new String(result.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8); - } else if (charset == null) { - Charset detected = CharsetHelper.detect(result); - if (detected == null) { - if (CharsetHelper.isUTF8(result)) { - Log.i("Charset plain=UTF8"); - result = new String(result.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8); - } + if (charset == null || StandardCharsets.ISO_8859_1.equals(cs)) + if (StandardCharsets.ISO_8859_1.equals(cs) && CharsetHelper.isUTF8(result)) { + Log.i("Charset upgrade=UTF8"); + result = new String(result.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8); } else { - Log.i("Charset plain=" + detected.name()); - result = new String(result.getBytes(StandardCharsets.ISO_8859_1), detected); + Charset detected = CharsetHelper.detect(result); + if (detected == null) { + if (CharsetHelper.isUTF8(result)) { + Log.i("Charset plain=UTF8"); + result = new String(result.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8); + } + } else { + Log.i("Charset plain=" + detected.name()); + result = new String(result.getBytes(StandardCharsets.ISO_8859_1), detected); + } } - } if ("flowed".equalsIgnoreCase(h.contentType.getParameter("format"))) result = HtmlHelper.flow(result);