mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-03 13:44:40 +00:00
Charset text/plain simplification
This commit is contained in:
parent
400a85da3e
commit
f87d59a7f3
1 changed files with 11 additions and 14 deletions
|
@ -1884,22 +1884,19 @@ public class MessageHelper {
|
|||
}
|
||||
|
||||
if (h.isPlainText()) {
|
||||
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 if (charset == null) {
|
||||
Charset detected = CharsetHelper.detect(result);
|
||||
if (StandardCharsets.ISO_8859_1.equals(cs) &&
|
||||
StandardCharsets.UTF_8.equals(detected)) {
|
||||
Log.i("Charset upgrade=UTF8");
|
||||
result = new String(result.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
|
||||
} else {
|
||||
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 (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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue