?public static String getUniStr(String str)
?{
??StringBuffer uniString = new StringBuffer();
??for (int i = 0; i < str.length(); i++)
??{
???Character ch = new Character(str.charAt(i));
???if (ch.toString().getBytes().length == 1)
???{
????uniString.append(ch.charValue());
???}
???else
???{ // double bytes character: Chinese
????int a = (int) ch.charValue();
????String tmp = new String("&#x" + Integer.toHexString(a) + ";");
????uniString.append(tmp);
???}
??}
??return uniString.toString();
?}
|----------------------------------------------------------------------------------------|
版權聲明 版權所有 @zhyiwww
引用請注明來源 http://www.aygfsteel.com/zhyiwww
|----------------------------------------------------------------------------------------|
posted on 2006-07-11 17:35
zhyiwww 閱讀(2081)
評論(2) 編輯 收藏 所屬分類:
java basic