mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-29 05:15:13 +02:00
EML: show detected charset
This commit is contained in:
@@ -48,11 +48,13 @@ public class CharsetHelper {
|
||||
static boolean isUTF8(String text) {
|
||||
// Get extended ASCII characters
|
||||
byte[] octets = text.getBytes(StandardCharsets.ISO_8859_1);
|
||||
return isUTF8(octets);
|
||||
}
|
||||
|
||||
static boolean isUTF8(byte[] octets) {
|
||||
CharsetDecoder utf8Decoder = StandardCharsets.UTF_8.newDecoder()
|
||||
.onMalformedInput(CodingErrorAction.REPORT)
|
||||
.onUnmappableCharacter(CodingErrorAction.REPORT);
|
||||
|
||||
try {
|
||||
utf8Decoder.decode(ByteBuffer.wrap(octets));
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user