自己查一查javadoc   中的String 类

解决方案 »

  1.   

    用j2sdk里自带的native2ascii.exe命令就可以了
      

  2.   

    unicode的前256个字符同ASCII是一样的
      

  3.   

    try
    {
    byte[] b = "你".getBytes("unicode");
    for(int i=0,iSize=b.length;i<iSize;i++)
    System.out.println(Integer.toHexString(b[i]));
    }
    catch(UnsupportedEncodingException e)
    {
    }
      

  4.   

    我想在程序中得到呢?应该用什么方法啊String类里面好像没有提供获得字符unicode的方法啊
      

  5.   

    在java里缺省就是unicode,不是你程序要得到,而是应该这样:
    如果你的字符来源于其他(文件、网络)那么就要在发送时候就指定是那种类型字符,在java再将他转换
      

  6.   

    那我怎么知道"中"的unicode是什么呢
    难道要自己用native2ascii.exe去转换,然后再打开自己看吗不能写一个程序算出来,整整齐齐的打印在屏幕上面吗?
      

  7.   

    String str = "中";
    byte[] b = str.getBytes("UTF-16");
    for(int i=0;i<b.length;i++)
    System.out.println(Integer.toHexString(b[i]));
      

  8.   

    Character.getNumericValue();一个函数就搞定了,要得着那么复杂?
    看看JavaDoc上怎么说的getNumericValuepublic static int getNumericValue(char ch)
    Returns the int value that the specified Unicode character represents. For example, the character '\u216C' (the roman numeral fifty) will return an int with a value of 50. The letters A-Z in their uppercase ('\u0041' through '\u005A'), lowercase ('\u0061' through '\u007A'), and full width variant ('\uFF21' through '\uFF3A' and '\uFF41' through '\uFF5A') forms have numeric values from 10 through 35. This is independent of the Unicode specification, which does not assign numeric values to these char values. If the character does not have a numeric value, then -1 is returned. If the character has a numeric value that cannot be represented as a nonnegative integer (for example, a fractional value), then -2 is returned. Parameters:
    ch - the character to be converted. 
    Returns:
    the numeric value of the character, as a nonnegative int value; -2 if the character has a numeric value that is not a nonnegative integer; -1 if the character has no numeric value.
    Since:
    1.1
    See Also:
    forDigit(int, int), isDigit(char
      

  9.   

    寒所有楼上的
    char c='中';
    System.out.println(Integer.toHexString(c));
    你可以反编译class看看对不对
    在class里面所有的字符串都被解析成unicode
    String的话用str.toCharArray()得到char串
      

  10.   

    String str = "中";
    byte[] b = str.getBytes("UTF-16");
    for(int i=0;i<b.length;i++)
    System.out.println(Integer.toHexString(b[i]));
    好像是有些问题的!
      

  11.   

    回复人: oneonone() ( ) 信誉:100  2004-04-05 19:37:00  得分:0 
     
     
      Character.getNumericValue();一个函数就搞定了,要得着那么复杂?
    ...
    -----------------------------------
    不能用