Skip to content

Instantly share code, notes, and snippets.

@dmikurube
Created June 22, 2015 13:27
Show Gist options
  • Save dmikurube/2bbfeec60b7daf3f2fe8 to your computer and use it in GitHub Desktop.
Save dmikurube/2bbfeec60b7daf3f2fe8 to your computer and use it in GitHub Desktop.
Bin
import java.nio.charset.Charset;
public class BinString {
public static void main(String[] args) {
byte[] array = new byte[3];
array[0] = (byte)0x9c;
array[1] = (byte)0xff;
array[2] = (byte)0xc9;
String str1 = new String(array, Charset.forName("ISO-8859-1"));
for (int i = 0; i < str1.length(); ++i) {
System.out.printf("%04x %c\n", (int)str1.charAt(i), str1.charAt(i));
}
String str2 = new String(array, Charset.forName("UTF-8"));
for (int i = 0; i < str2.length(); ++i) {
System.out.printf("%04x %c\n", (int)str2.charAt(i), str2.charAt(i));
}
}
}
@dmikurube
Copy link
Author

009c ?
00ff ?
00c9 ?
fffd ?
fffd ?
fffd ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment