mirror of https://github.com/M66B/FairEmail.git
Refactoring
This commit is contained in:
parent
d5eca31bc3
commit
d0d4d15899
|
@ -663,22 +663,8 @@ public class MessageHelper {
|
||||||
} catch (UnsupportedEncodingException ex) {
|
} catch (UnsupportedEncodingException ex) {
|
||||||
Log.w(ex);
|
Log.w(ex);
|
||||||
}
|
}
|
||||||
} else {
|
} else
|
||||||
// Fix UTF-8 plain header
|
subject = fixUTF8(subject);
|
||||||
try {
|
|
||||||
char[] kars = subject.toCharArray();
|
|
||||||
byte[] bytes = new byte[kars.length];
|
|
||||||
for (int i = 0; i < kars.length; i++)
|
|
||||||
bytes[i] = (byte) kars[i];
|
|
||||||
|
|
||||||
CharsetDecoder cs = StandardCharsets.UTF_8.newDecoder();
|
|
||||||
CharBuffer out = cs.decode(ByteBuffer.wrap(bytes));
|
|
||||||
if (out.length() > 0)
|
|
||||||
subject = new String(bytes, StandardCharsets.UTF_8);
|
|
||||||
} catch (CharacterCodingException ex) {
|
|
||||||
Log.w(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return decodeMime(subject);
|
return decodeMime(subject);
|
||||||
}
|
}
|
||||||
|
@ -798,6 +784,24 @@ public class MessageHelper {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static String fixUTF8(String text) {
|
||||||
|
try {
|
||||||
|
char[] kars = text.toCharArray();
|
||||||
|
byte[] bytes = new byte[kars.length];
|
||||||
|
for (int i = 0; i < kars.length; i++)
|
||||||
|
bytes[i] = (byte) kars[i];
|
||||||
|
|
||||||
|
CharsetDecoder cs = StandardCharsets.UTF_8.newDecoder();
|
||||||
|
CharBuffer out = cs.decode(ByteBuffer.wrap(bytes));
|
||||||
|
if (out.length() > 0)
|
||||||
|
return new String(bytes, StandardCharsets.UTF_8);
|
||||||
|
} catch (CharacterCodingException ex) {
|
||||||
|
Log.w(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
static String getSortKey(Address[] addresses) {
|
static String getSortKey(Address[] addresses) {
|
||||||
if (addresses == null || addresses.length == 0)
|
if (addresses == null || addresses.length == 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in New Issue