你看一下这里有没有
《Java 编程技术中汉字问题的分析及解决》http://blue_zhou.myetang.com/src/dev/java/Java%B1%E0%B3%CC%BC%BC%CA%F5%D6%D0%BA%BA%D7%D6%CE%CA%CC%E2%B5%C4%B7%D6%CE%F6%BC%B0%BD%E2%BE%F6.htm

解决方案 »

  1.   

    Stirng str="我";
    byte[] bs=str.toCharArray();
      

  2.   

    char c = '铃';
    int code = (int) c;我刚试了一下,其他汉字都没问题,唯独‘铃’字不行,可能是我的系统是日文系统的原因。
    晚上我回家用中文系统再试一下。应该没问题的。
      

  3.   

    小猪的程序是:class b
    {


    public static void main(String arge[] )
    {
    String s1="aAbBcC";
    byte[] b1=s1.getBytes();

    String s2="铃";
    byte[] b2=s2.getBytes();

    char c='铃';
    int i=(int)c;



    System.out.println(i);

    for(int j=0;j<b1.length;j++)
    {
      System.out.println(b1[j]);
    }

    for(int j=0;j<b2.length;j++)
    {
      System.out.println(b2[j]);
    }

    }

    }
    ************************************************
    ************************************************
    结果是:
    38083
    97
    65
    98
    66
    99
    67
    -63
    -27
    Press any key to continue...
      

  4.   

    class HelloUnicode {
        /**
         * main entrance
         * @param args command line arguments
         */
        public static void main(String[] args) {
            String hello = "Hello world 世界你好";        //read from command line input
            if (args.length > 0) {
                hello = args[0];
            }        try {
                /*
                 * 试验1: 从测试字符串按系统缺省编码方式解码,并写入文件
                 */
                System.out.println(">>>>testing1: write hello world to files<<<<");
                System.out.println("[test 1-1]: with system default encoding="
                    + System.getProperty("file.encoding") + "\nstring=" + hello
                    + "\tlength=" + hello.length());
                printCharArray(hello);
                //把字符串按GB2312解码
                hello = new String(hello.getBytes(), "GB2312");
                System.out.println(
                    "[test 1-2]: getBytes with platform default encoding and decoding as gb2312:\nstring="
                    + hello + "\tlength=" + hello.length());
                printCharArray(hello);
            } catch (Exception e) {
                System.out.println(e.toString());
            }
        }    /**
         * print char array
         * @param inStr input string
         */
        public static void printCharArray(String inStr) {
            char[] myBuffer = inStr.toCharArray();        //list each Charactor in byte value, short value, and UnicodeBlock Mapping
            for (int i = 0; i < inStr.length(); i++) {
                byte b = (byte) myBuffer[i];
                short s = (short) myBuffer[i];
                String hexB = Integer.toHexString(b).toUpperCase();
                String hexS = Integer.toHexString(s).toUpperCase();
                StringBuffer sb = new StringBuffer();            //print char
                sb.append("char[");
                sb.append(i);
                sb.append("]='");
                sb.append(myBuffer[i]);
                sb.append("'\t");            //byte value
                sb.append("byte=");
                sb.append(b);
                sb.append(" \\u");
                sb.append(hexB);
                sb.append('\t');            //short value
                sb.append("short=");
                sb.append(s);
                sb.append(" \\u");
                sb.append(hexS);
                sb.append('\t');            //Unicode Block 双字节的为中日韩文
                sb.append(Character.UnicodeBlock.of(myBuffer[i]));            System.out.println(sb.toString());
            }        System.out.println();
        }
    }
      

  5.   

    String strUTF=new String("你好");
    byte[] byteUTF = strUTF.getBytes("Unicode");
    for(int i=2;i<byteUTF.length;i++)
        System.out.println(Integer.toHexString(byteUTF[i]));
      

  6.   

    String str = "玲";
    byte[] b = str.getBytes();int a = b[0];
    a = a * 100 + b[1];
    a = a - 1;a就是他的内吗
      

  7.   

    TO  Danger2000(飞鱼) :     byte[] byteUTF = strUTF.getBytes("Unicode");
                                        //-----------
                                        //需要这个吗?"Unicode"它有什么用?
         for(int i=2;i<byteUTF.length;i++)
         System.out.println(Integer.toHexString(byteUTF[i]));
                                   //----------------------
                                   //这个方法是转为16进制吗?
                                   //可以解释一下  i  循环的道理吗?TO  zhang21cnboy(事了抚衣去,不留身与名):    可以说说你的程序是什么意思吗? 
      

  8.   

    to sbojuqqk(小猪快跑!) :
    byte[] getBytes(String charsetName) 
              Encodes this String into a sequence of bytes using the named charset, storing the result into a new byte array. (根据字符集编码)toHexString()是转为16进制,i取出byteUTF[]中的除了前2位的剩余内容。
      

  9.   

    TO Danger2000(飞鱼) :谢谢你的解释。我不明白i为什么从第三位开始,10->8   16->10   
    8->10   的方法是什么?
      

  10.   

    “char c = '铃';
    int code = (int) c;”唯一正确答案,用getBytes()的需要看看Unicode文档
      

  11.   

    to sbojuqqk(小猪快跑!)
    前2位应该是Unicode编码的标志吧,前2位以后才是字符的编码。
      

  12.   

    to 鱼:
         谢谢!I KNOW。