Created
June 22, 2015 13:27
-
-
Save dmikurube/2bbfeec60b7daf3f2fe8 to your computer and use it in GitHub Desktop.
Bin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
009c ?
00ff ?
00c9 ?
fffd ?
fffd ?
fffd ?