我使用了一种极其笨拙的方法:
tempInt = Integer.valueOf(tempString,16); 
tempString = String.valueOf(tempInt);
int[] spwanArray = new int[1];
spwanArray[0] = tempInt;
String spawnString = new String(spwanArray,0,1);
decodedString += spawnString;
是不是很笨拙?那位老兄能够给个舒服点的方法?谢谢

解决方案 »

  1.   

    怎么那么复杂啊,看看这个行不行:public class Word
    {
    public static void main(String[] args)
    {
    int[] uchars = {
    67, 83, 68, 78, 35770, 22363,
    0x43, 0x53, 0x44, 0x4e, 0x8bba, 0x575b
    };
    String str = "";
    for(int i=0; i<uchars.length; i++)
    {
    str+=(char)uchars[i];
    }
    System.out.println(str);

    String s = new String("\u0043\u0053\u0044\u004e\u8bba\u575b");
    System.out.println(s);
    }
    }
      

  2.   

    jdk有个工具native2ascii,带上参数-reverse就可实现上面的功能
      

  3.   

    使用java.util.Properties类的源代码里面的这两个方法/*
         * Converts encoded &#92;uxxxx to unicode chars
         * and changes special saved chars to their original forms
         */
    private String loadConvert(String theString)  /*
         * Converts unicodes to encoded &#92;uxxxx
         * and writes out any of the characters in specialSaveChars
         * with a preceding slash
         */
    private String saveConvert(String theString, boolean escapeSpace)他们就符合你的要求,这两个方法的代码比较常,原因是其中的10进制数和16进制的转换没有使用Integer类里面的现成的方法,而是自己直接使用算法转换的。。
      

  4.   

    回头看看好想只要这样就ok了,java中所有东东都是Unicode嘛:)
    System.out.println("\u0043\u0053\u0044");