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.blogjava.net/zhyiwww
|----------------------------------------------------------------------------------------|
posted on 2006-07-11 17:35
zhyiwww 阅读(2065)
评论(2) 编辑 收藏 所属分类:
java basic