mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-06 00:53:26 +02:00
Charset improvements
This commit is contained in:
@@ -882,15 +882,19 @@ public class MessageHelper {
|
||||
if (charset != null) {
|
||||
charset = charset.replace("\"", "");
|
||||
if ("ASCII".equals(charset.toUpperCase()))
|
||||
charset = "us-ascii";
|
||||
charset = "US-ASCII";
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(charset) || "US-ASCII".equals(charset.toUpperCase())) {
|
||||
// The first 127 characters are the same as in US-ASCII
|
||||
result = new String(result.getBytes(StandardCharsets.ISO_8859_1));
|
||||
} else {
|
||||
if ("US-ASCII".equals(Charset.forName(charset).name()))
|
||||
// See UnknownCharsetProvider class
|
||||
if ("US-ASCII".equals(Charset.forName(charset).name())) {
|
||||
Log.w("Unsupported encoding charset=" + charset);
|
||||
warnings.add(context.getString(R.string.title_no_charset, charset));
|
||||
result = new String(result.getBytes(StandardCharsets.ISO_8859_1));
|
||||
}
|
||||
}
|
||||
} catch (ParseException ex) {
|
||||
Log.w(ex);
|
||||
|
||||
@@ -20,6 +20,7 @@ package eu.faircode.email;
|
||||
*/
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.charset.spi.CharsetProvider;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
@@ -36,8 +37,9 @@ public class UnknownCharsetProvider extends CharsetProvider {
|
||||
// UseInqueCodePage
|
||||
// none
|
||||
// unknown-8bit
|
||||
// X-UNKNOWN
|
||||
// https://javaee.github.io/javamail/FAQ#unsupen
|
||||
Log.w("Unknown charset=" + name);
|
||||
return Charset.forName("US-ASCII");
|
||||
Log.e("Unknown charset=" + name);
|
||||
return StandardCharsets.US_ASCII;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user