Skip to content

Instantly share code, notes, and snippets.

@tixel
Created April 27, 2012 15:50
Show Gist options
  • Save tixel/2510316 to your computer and use it in GitHub Desktop.
Save tixel/2510316 to your computer and use it in GitHub Desktop.
convert charsets
Charset utf8charset = Charset.forName("UTF-8"); Charset iso88591charset = Charset.forName("ISO-8859-1"); ByteBuffer inputBuffer = ByteBuffer.wrap(new Byte[]{(byte)0xC3, (byte)0xA2}); // decode UTF-8 CharBuffer data = utf8charset.decode(inputBuffer); // encode ISO-8559-1 ByteBuffer outputBuffer = iso88591charset.encode(data); byte[] outputData = outputBuffer.array();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment