Java代码:
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;
}
原文地址:https://blog.youkuaiyun.com/u013066244/article/details/54708179
仅供学习交流,侵删
本文介绍了一种在Java中将Unicode编码转换为普通字符串的方法。通过使用正则表达式匹配Unicode编码,并将其转换为对应的字符,实现了Unicode字符串的正确解析。
2031

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



