UTF-8码怎么中文显示出来?

ema 2004-03-31 02:57:45
如下一组:
\u6e38\u5ba2\u65e0\u6b64\u6743\u9650\uff01
\u7528\u6237\u4e0d\u5b58\u5728\uff01
\u6635\u79f0\u4e0d\u80fd\u4e3a\u7a7a\uff01
...
怎么显示成中文?
...全文
609 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
woidan 2004-04-02
  • 打赏
  • 举报
回复
在jb中打开即可自动转化为中文。
ema 2004-03-31
  • 打赏
  • 举报
回复
我碰到个网页如下:
<%@ page contentType="text/html; charset=UTF-8"%>
<html>
<head>
<title>椤甸潰瑁呰浇</title>
<table border="0" cellpadding="0" cellspacing="0" width="300">
<tr>
<td class='T1' height="25">
<p align="center"><span class='bt'><font color='#ffffff'><B>鎿嶄綔缁撴灉</B></font></span></td>
</tr>
<tr>
<td class='T2' align="center"><BR><span class='bt'>
<font color='#ff0000'><bean:message key="<%=aForwardInfo.getMsg()%>"/></font></span><BR><BR>
</td>
</tr>
<tr>
<td class='T1' height="25">
<p align="center">
</body>
</html>

能把里面的那些汉字乱码转化为中文吗?
romantic8899 2004-03-31
  • 打赏
  • 举报
回复
native2ascii.exe
muymuy 2004-03-31
  • 打赏
  • 举报
回复
public class EncodeDemo {
public static void main(String args[]) {
//简单的办法
String s1 = "\u6e38\u5ba2\u65e0\u6b64\u6743\u9650\uff01";
String s2 = "\u7528\u6237\u4e0d\u5b58\u5728\uff01";
String s3 = "\u6635\u79f0\u4e0d\u80fd\u4e3a\u7a7a\uff01";
System.out.println(s1);
System.out.println(s2);
System.out.println(s3);

//复杂的办法
String s11 = "\\u6e38\\u5ba2\\u65e0\\u6b64\\u6743\\u9650\\uff01";
String s12 = "\\u7528\\u6237\\u4e0d\\u5b58\\u5728\\uff01";
String s13 = "\\u6635\\u79f0\\u4e0d\\u80fd\\u4e3a\\u7a7a\\uff01";
System.out.println(encode(s11));
System.out.println(encode(s12));
System.out.println(encode(s13));
}

private static String encode(String s) {
int pos = 0;
StringBuffer sb = new StringBuffer();
while (pos < s.length()) {
switch (s.charAt(pos)) {
case '\\' : {
if (s.charAt(pos + 1) == 'u'){
pos += 2;
char c = (char)Integer.parseInt(s.substring(pos, pos + 4), 16);
sb.append(c);
pos += 4;
} else {
sb.append('\\');
pos ++;
}
break;
}
default: {
sb.append(s.charAt(pos));
pos++;
}
}
}
return sb.toString();
}
}
Koham 2004-03-31
  • 打赏
  • 举报
回复
直接打印就可以了,不需要其他操作

62,623

社区成员

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

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