请问各位大侠,用JAVA语言怎样得到一个汉字的内码?比如“中”的内码?
谢谢。在线等待...

解决方案 »

  1.   

    don't know and help up
      

  2.   

    String sring="中";
    string.getBytes("GBK");返回的就是他在GBK字符集中的内码。
      

  3.   

    byte 型的数据怎么样才能打印出来啊?
      

  4.   

    String s = "中a历史";
            for (int i = 0; i < s.getBytes().length; i++) {
                System.out.println(s.getBytes()[i]);
            }
            for (int j = 0; j < s.length(); j++) {
                System.out.println(s.charAt(j));
            }---初学者
      

  5.   

    不明白你说的内码是什么意思,如果是unicode编码(因为java对字符编码的支持是32位的unicode编码),看下面的程序public class Uni { public static void main(String[] args) {
    char ch='中';
    int a;
    a=(int)ch;
    System.out.println("中的unicode编码为:"+a);
    }
    }
      

  6.   

    如果是二进制编码,看这个程序:public class Uni { public static void main(String[] args) {
    char ch='中';
    int a=(int)ch,kongge=0;
    long m=1;
    m<<=31;

    System.out.println("\"中\"的二进制编码为:");
    for(;m!=0;m>>>=1){
    if ((a&m)!=0)
    System.out.print("1");
    else
    System.out.print("0");

    kongge++;
    if((kongge%8)==0)
    System.out.print(" ");
    }
    }
    }