接口返回的xml字符转码问题

Leon Leo 2013-01-25 10:56:18
<EmployeeName>陈成业</EmployeeName>

如何转换为汉字?
...全文
168 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
suciver 2013-01-25
  • 打赏
  • 举报
回复
引用 3 楼 flagiris 的回复:
Java code public static String unicodeToString(String str) { Pattern pattern = Pattern.compile("(&#x(\\p{XDigit}{4}))"); Matcher matcher = pattern.matcher(str); ……
+1
菖蒲老先生 2013-01-25
  • 打赏
  • 举报
回复

	public static String unicodeToString(String str) {
		Pattern pattern = Pattern.compile("(&#x(\\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;
	}
Leon Leo 2013-01-25
  • 打赏
  • 举报
回复
可以这样?没尝试过
老9 2013-01-25
  • 打赏
  • 举报
回复
在组装返回时用 <EmployeeName><![CDATA[ 中文 ]]</EmployeeName>

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧