Messaging: Use StandardCharsets where possible

Change-Id: I45a19c47262116d34260e1957145580a7f97168e
This commit is contained in:
Michael W
2024-12-26 14:55:13 +01:00
parent a2f67b4f7b
commit fd63d5f125
12 changed files with 33 additions and 61 deletions
+3 -11
View File
@@ -33,7 +33,6 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Method;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
@@ -41,6 +40,7 @@ import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.Proxy;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -439,16 +439,8 @@ public class MmsHttpClient {
nai = nai + naiSuffix;
}
byte[] encoded = null;
try {
encoded = Base64.encode(nai.getBytes("UTF-8"), Base64.NO_WRAP);
} catch (UnsupportedEncodingException e) {
encoded = Base64.encode(nai.getBytes(), Base64.NO_WRAP);
}
try {
return new String(encoded, "UTF-8");
} catch (UnsupportedEncodingException e) {
return new String(encoded);
}
encoded = Base64.encode(nai.getBytes(StandardCharsets.UTF_8), Base64.NO_WRAP);
return new String(encoded, StandardCharsets.UTF_8);
}
return null;
}
@@ -25,6 +25,7 @@ import androidx.annotation.NonNull;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
/**
@@ -146,11 +147,7 @@ public class EncodedStringValue implements Cloneable {
if (LOCAL_LOGV) {
Log.v(TAG, e.getMessage(), e);
}
try {
return new String(mData, CharacterSets.MIMENAME_ISO_8859_1);
} catch (UnsupportedEncodingException e2) {
return new String(mData); // system default encoding.
}
return new String(mData, StandardCharsets.ISO_8859_1);
}
}
}