Charset improvements

This commit is contained in:
M66B
2019-09-25 08:32:05 +02:00
parent 53da2fef86
commit 4e1e9db314
3 changed files with 13 additions and 4 deletions

View File

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