mirror of
https://github.com/M66B/FairEmail.git
synced 2025-03-15 08:29:24 +00:00
Charset improvements
This commit is contained in:
parent
53da2fef86
commit
4e1e9db314
3 changed files with 13 additions and 4 deletions
3
FAQ.md
3
FAQ.md
|
@ -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…
Add table
Reference in a new issue