static Pattern p = Pattern.compile("////u([0123456789abcdef]{4})"); public static String stringToUnicode(String s) { Matcher matcher = p.matcher(s); StringBuffer buffer = new StringBuffer(); while (matcher.find()) { int codePoint = Integer.parseInt(matcher.group(1), 16); matcher.appendReplacement(buffer, ""); buffer.appendCodePoint(codePoint); } matcher.appendTail(buffer); return buffer.toString(); } public static void main(String[] args) { System.out.println(stringToUnicode("//u5145//u503c//u6210//u529f")); }
java unicode转换代码
最新推荐文章于 2022-05-23 18:13:12 发布
本文介绍了一个简单的Java程序,该程序能够将包含Unicode转义序列的字符串转换为对应的Unicode字符。通过正则表达式匹配转义序列并将其转换成实际的字符。
251

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



