/**
* 将十进制形式的Unicode编码转换为字符,例如 36215->北 (起)
* @param codePoints
* @return
*/
public static String fromCharCode(int... codePoints) {
StringBuilder builder = new StringBuilder(codePoints.length);
for (int codePoint : codePoints){
builder.append(Character.toChars(codePoint));
}
return builder.toString();
}
/**
* 将起飞 转化为 只含有整数值的数组 result[0]=36215,result[1]=39134
* @param unicodeStr
* @return
*/
public static int[] removeUnicodeFlag(String unicodeStr){
String regex = "&#(
\\d+);";
int result[] = new int[unicodeStr.split(";").length];
Pattern p = Pattern.compile(regex);
Matcher ma = p.matcher(unicodeStr);
int i = 0;
while (ma.find()) {
result[i++] = Integer.parseInt(ma.group(1));
}
return result;
}
转载于:https://www.cnblogs.com/quechao123/archive/2011/09/04/2346601.html