public class test {
     public static void main(String[] args) {
      System.out.println("\u6CA1\u6709\u5B9A\u4E49\u4EFB\u52A1\u914D\u7F6E\u6587\u4EF6\uFF01");
     }
}
就是这个以\u开始的编码,有知道的吗?能详细解释下吗?

解决方案 »

  1.   

    介绍可以看这儿http://tech.idv2.com/2008/02/21/unicode-intro/
      

  2.   

    是Unicode码   包含了世界各国所有语言的字符  创建这种码的原因是将java的编码国际化 使语言更统一
      

  3.   


    public class StringToUnicode {
    public static String StringToUnicode(String str) {
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < str.length(); i++) {
            int temp = (int) str.charAt(i);//获取字符的编码,但是十进制的
            String hex = Integer.toHexString(temp);//获得字符的16进制编码
                while (hex.length() != 4) {//不足4位加0补齐
                hex = "0"+hex;
                }
            hex = new String(hex).toUpperCase();// 把编码转换成大写
            sb.append("\\u" + hex);
        }
    return sb.toString();
    }
    public static void main(String[] args) {
        StringToUnicode t =new StringToUnicode();
        System.out.println(t.StringToUnicode(args[0]));
    }
    }搞懂老,谢谢各位,这是一个字符转unicode码的java程序,希望各位多指点