string
public static void main(String[] args) throws InterruptedException, IOException {
byte[] utf8bs = {(byte) 0xe3, (byte) 0x80, (byte) 0x8a, (byte) 0xe6, (byte) 0x80, (byte) 0x81,
(byte) 0xe5, (byte) 0xba, (byte) 0xa6, (byte) 0xe5, (byte) 0x85, (byte) 0xac, (byte) 0xe5,
(byte) 0xbc, (byte) 0x80, (byte) 0xe8, (byte) 0xaf, (byte) 0xbe, (byte) 0xe3, (byte) 0x80,
(byte) 0x8b, (byte) 0xe5, (byte) 0xbc, (byte) 0x80, (byte) 0xe8, (byte) 0xae, (byte) 0xb2,
(byte) 0xe5, (byte) 0x95, (byte) 0xa6,};
byte[] gb2312bs = {(byte) 0xa1, (byte) 0xb6, (byte) 0xcc, (byte) 0xac, (byte) 0xb6, (byte) 0xc8,
(byte) 0xb9, (byte) 0xab, (byte) 0xbf, (byte) 0xaa, (byte) 0xbf, (byte) 0xce, (byte) 0xa1,
(byte) 0xb7, (byte) 0xbf, (byte) 0xaa, (byte) 0xbd, (byte) 0xb2, (byte) 0xc0, (byte) 0xb2,};
String us = new String(utf8bs);
String gs = new String(gb2312bs, "gb2312");
System.out.println(new String(gs.getBytes("gbk"), "gb2312"));
System.out.println(new String(us.getBytes("gb18030"), "gbk"));
// java.util.SortedMap<String, Charset> map = Charset.availableCharsets();
// java.util.Set<String> key = map.keySet();
// for (String string : key) {
// System.out.println("key:" + string + "--value:" + map.get(string));
// }
printChars(us);
printChars(gs);
printBs(us.getBytes());
printBs(gs.getBytes("gb2312"));
}
public static void printBs(byte[] bs) {
System.out.println("");
for (int i = 0; i < bs.length; i++) {
int j = bs[i];
String s = "0x" + Integer.toHexString(j);
System.out.print(s + "\t");
if ((i + 1) % 5 == 0) {
System.out.println("");
}
}
}
public static void printChars(String b) {
System.out.println("");
for (int i = 0; i < b.length(); i++) {
char j = b.charAt(i);
String s = "0x" + Integer.toHexString(j);
System.out.print(s + j + "\t");
if ((i + 1) % 5 == 0) {
System.out.println("");
}
}
}
//http://g.163.com/r?site=netease&affiliate=homepage&cat=homepage&type=hptoptextlink&location=1
2000 xxd
2001 ls
2002 iconv -l
2003 iconv -f gb2312 -t utf-16be b.txt -o d.txt
2004 vi d.txt
2005 iconv -f gb2312 -t utf8 b.txt -o d.txt
2006 vi d.txt
2007 iconv -f gb2312 -t utf-16be b.txt -o d.txt
2008 vi d.txt