用System.out.println打印,然后复制,粘贴,呵呵

解决方案 »

  1.   

    public static void main(String[] args) {
        try {
          //从文本中或其它方式读出
          String message="\\u5173\\u4e8e";
          String[] msgs=message.split("\\\\u");
          StringBuffer result=new StringBuffer();
          for (int it = 0; it < msgs.length; it++) {
            String msg = msgs[it].trim();
            if(msg.length()>=1) {
              char chr=(char)Integer.parseInt(msg,16);
              result.append(chr);
            }
          }
          System.out.println("result= '" + result.toString() + "'");
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
      

  2.   

    private String string2Unicode(String s){            StringBuffer result=new StringBuffer();            int i;            for(i=0;i<s.length();i++){                   if(s.charAt(i)>=0x007f){                          result.append('\\');                          result.append('u');                          String hex=Integer.toHexString(s.charAt(i));                          System.out.println(s.charAt(i)+":"+hex);                          result.append(hex);                   }                   else {                                 if(s.charAt(i)==0x5c){                                        result.append("\\u005c");                                }                                else{                                       result.append(s.charAt(i));                           }                   }                               }            return result.toString();       }
    我这个函数就是把u5173\u4e8e之类的字符符转换成unicode的字符的
    这是在J2ME中解决中文问题的一个方案
    http://www.kspig.com/bbsxp/ShowPost.asp?id=1377