首页 > 代码库 > Unicode字符转换成字符串

Unicode字符转换成字符串

/***
* Unicode字符转换成字符串
* @param str
* Unicode字符
* @return
* String
*
* @author WXW
*/
public static String Unicode2String(String str){
Pattern pattern = Pattern.compile("(\\\\u(\\p{XDigit}{4}))");
Matcher matcher = pattern.matcher(str);
char ch;
while(matcher.find()){
ch = (char)Integer.parseInt(matcher.group(2),16);
str = str.replace(matcher.group(1), ch+"");
}
return str;
}

Unicode字符转换成字符串