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();
}
{
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();
}