public class 中文字符转GBK码{
public static void main(String[] args) throws Exception {
String s=new String("座".getBytes(),"unicode");
StringBuilder sb=new StringBuilder();
for(Character c:s.toCharArray()){
sb.append(Integer.toBinaryString(c));
}
System.out.println(String.format("%4x", Long.parseLong(sb.toString(), 2)));
}
}
public static void main(String[] args) throws Exception {
String s=new String("座".getBytes(),"unicode");
StringBuilder sb=new StringBuilder();
for(Character c:s.toCharArray()){
sb.append(Integer.toBinaryString(c));
}
System.out.println(String.format("%4x", Long.parseLong(sb.toString(), 2)));
}
}