Charset improvements

pull/162/head
M66B 5 years ago
parent 53da2fef86
commit 4e1e9db314

@ -718,6 +718,9 @@ Account permissions are required to periodically refresh the [OAuth](https://dev
(a kind of password used to login to your Gmail account).
Just start the wizard (but do not select an account) to grant the required permissions again.
The warning *... Unsupported encoding ...* means that the character set of the message is unknown or not supported.
FairEmail will assume ISO-8859-1 (Latin1), which will in most cases result in showing the message correctly.
See [here](https://linux.die.net/man/3/connect) for what error codes like EHOSTUNREACH and ETIMEDOUT mean.
Possible causes are:

@ -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;
}
}

Loading…
Cancel
Save