转Unicode为汉字方法

Posted on 2007-11-08 13:49 my 阅读(671) 评论(0)  编辑  收藏 所属分类: 个人收藏
String str = "&# 20013;&# 25991;";

public synchronized static String converUnicodeToCN(String str){
    String tmp = str.replaceAll("&#",",").replaceAll(";","");
    String [] s2 = tmp.split(",");
    String s1 = "";
    for (int i=1;i<s2.length;i++){
      int a = Integer.parseInt(s2[i],10);
      s1 = s1+(char)a;
    }
    return s1;
 }

打印"中文"

备记

只有注册用户登录后才能发表评论。


网站导航:
 

posts - 63, comments - 45, trackbacks - 0, articles - 99

Copyright © my