?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
|----------------------------------------------------------------------------------------|