/**
* 把十六进制Unicode编码字符串转换为中文字符串
*/
public static String unicodeToString(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;
}
JAVA 把十六进制Unicode编码字符串转换为中文字符串
最新推荐文章于 2023-03-28 13:51:00 发布
本文介绍了一种将十六进制Unicode编码字符串转换为中文字符串的方法。通过使用正则表达式匹配并替换的方式,实现从Unicode编码到相应中文字符的转换。

1158

被折叠的 条评论
为什么被折叠?



