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
@@ -59,7 +59,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Map;
@@ -1632,26 +1632,14 @@ public class PduPersister {
* Wrap a byte[] into a String.
*/
public static String toIsoString(final byte[] bytes) {
try {
return new String(bytes, CharacterSets.MIMENAME_ISO_8859_1);
} catch (final UnsupportedEncodingException e) {
// Impossible to reach here!
Log.e(TAG, "ISO_8859_1 must be supported!", e);
return "";
}
return new String(bytes, StandardCharsets.ISO_8859_1);
}
/**
* Unpack a given String into a byte[].
*/
public static byte[] getBytes(final String data) {
try {
return data.getBytes(CharacterSets.MIMENAME_ISO_8859_1);
} catch (final UnsupportedEncodingException e) {
// Impossible to reach here!
Log.e(TAG, "ISO_8859_1 must be supported!", e);
return new byte[0];
}
return data.getBytes(StandardCharsets.ISO_8859_1);
}
/**