我想输出一个汉字的unicode编码,
该怎么办呀??
最好用printf()方法.

解决方案 »

  1.   

     在dos 环境下输入native2ascii打回车,输入所要转换的中文文字,再打回车,中文转换为unicode编码
      

  2.   

    String s = "\u0057\u0065\u006C\u0063\u006F\u006D\u0065";
    该语句打印出来的结果是字符串“Welcome”
       转义序列的形式为\uyyyy,其中yyyy表示四位十六进制码值。
       通过不同的码值我们可以表示不同国家的各种符号,Unicode联盟的网站有一个到码表的链接,列出了16位码值。英语,法语,德语,葡萄牙语和西班牙语字符都在Basic Latin区,日语字符在Hiragana区,俄语字符在Cyrillic区,汉语字符在CJK Unified Ideographs 区。
      

  3.   


    System.out.println((int)'我');
      

  4.   

    Ailen5 的方法最方便了
    哈哈!
    牛!
      

  5.   

    public String toUnicode(String str) {
    char[]arChar=str.toCharArray();
    int iValue=0;
    String uStr="";
    for(int i=0;i<arChar.length;i++) {
    iValue=(int)str.charAt(i);
    if(iValue<=256){
    uStr+="/u00"+Integer.toHexString(iValue).toUpperCase();
    }else{
    uStr+="/u"+Integer.toHexString(iValue).toUpperCase();
    }
    }
          return uStr;
    }
    纯JAVA写的一个转unicode的方法
      

  6.   

    public class CharTest {
        public static void main(String[] args) {
            char c = '国';
            // System.out.printf 仅在 JDK 1.5 及以上的版本有效
            System.out.printf("“%c”的Unicode编码:%04X%n", c, (int)c);
        }
    }