Fixed incorrect transform from UTF-16 to US-ASCII

This commit is contained in:
M66B
2022-06-10 12:39:53 +02:00
parent da44c936be
commit c2552cd744
3 changed files with 18 additions and 2 deletions

View File

@@ -3229,10 +3229,10 @@ public class MessageHelper {
try {
if (CHARSET16.contains(cs)) {
Charset detected = CharsetHelper.detect(result, cs);
// UTF-16 can be detected as US-ASCII
if (!CHARSET16.contains(detected))
Log.w(new Throwable("Charset=" + cs + " detected=" + detected));
if (StandardCharsets.US_ASCII.equals(detected) ||
StandardCharsets.UTF_8.equals(detected)) {
if (StandardCharsets.UTF_8.equals(detected)) {
charset = null;
result = new String(result.getBytes(cs), detected);
}