Android Utililty Methods Charset Decode

List of utility methods to do Charset Decode


The list of methods to do Charset Decode are organized into topic(s).


booleancanEncode(char c)
Determines whether or not this platform's Charset#defaultCharset default Charset ) can encode c and then decode it back to the exact same value.
try {
    char[] charArray = new char[] { c };
    ByteBuffer byteBuffer = Charset.defaultCharset().newEncoder()
    char[] charArrayRestored = Charset.defaultCharset()
    return (charArray[0] == charArrayRestored[0]);
} catch (CharacterCodingException cce) {
byte[]getBytes(String input, Charset charset)
Returns a new byte array containing the characters of the specified string encoded using the given charset.
CharBuffer chars = CharBuffer.wrap(input.toCharArray());
CharsetEncoder encoder = charset.newEncoder()
ByteBuffer buffer;
buffer = encode(chars.asReadOnlyBuffer(), encoder);
byte[] bytes = new byte[buffer.limit()];