html unicode问题

nry19871012 2018-01-20 05:37:30
1.用ajax查询数据,访问数据库得到html格式的字符串如下 A
2.调试前台ajax 返回成功得到的值变为了 如下 B,一些特殊符号被转换成了unicode码,
如 < 被转成了 \u003c ,在JS中如何将 \u003c 还原成<
3.如何正常显示带HTML格式的网页。

A

<html>\r\n\r\n<head>\r\n<meta http-equiv=Content-Type content=\"text/html; charset=gb2312\">\r\n<meta name=Generator content=\"Microsoft Word 14 (filtered)\">\r\n<style>\r\n<!--\r\n /* Font Definitions */\r\n @font-face\r\n\t{font-family:宋体;\r\n\tpanose-1:2 1 6 0 3 1 1 1 1 1;}\r\n@font-face\r\n\t{font-family:宋体;\r\n\tpanose-1:2 1 6 0 3 1 1 1 1 1;}\r\n@font-face\r\n\t{font-family:Calibri;\r\n\tpanose-1:2 15 5 2 2 2 4 3 2 4;}\r\n@font-face\r\n\t{font-family:\"\\@宋体\";\r\n\tpanose-1:2 1 6 0 3 1 1 1 1 1;}\r\n /* Style Definitions */\r\n p.MsoNormal, li.MsoNormal, div.MsoNormal\r\n\t{margin:0cm;\r\n\tmargin-bottom:.0001pt;\r\n\ttext-align:justify;\r\n\ttext-justify:inter-ideograph;\r\n\tfont-size:10.5pt;\r\n\tfont-family:\"Calibri\",\"sans-serif\";}\r\nh1\r\n\t{mso-style-link:\"标题 1 Char\";\r\n\tmargin-right:0cm;\r\n\tmargin-left:0cm;\r\n\tfont-size:24.0pt;\r\n\tfont-family:宋体;}\r\np.MsoHeader, li.MsoHeader, div.MsoHeader\r\n\t{mso-style-link:\"页眉 Char\";\r\n\tmargin:0cm;\r\n\tmargin-bottom:.0001pt;\r\n\ttext-align:center;\r\n\tlayout-grid-mode:char;\r\n\tborder:none;\r\n\tpadding:0cm;\r\n\tfont-size:9.0pt;\r\n\tfont-family:\"Calibri\",\"sans-serif\";}\r\np.MsoFooter, li.MsoFooter, div.MsoFooter\r\n\t{mso-style-link:\"页脚


B

\u003chtml\u003e\r\n\r\n\u003chead\u003e\r\n\u003cmeta http-equiv=Content-Type content=\"text/html; charset=gb2312\"\u003e\r\n\u003cmeta name=Generator content=\"Microsoft Word 14 (filtered)\"\u003e\r\n\u003cstyle\u003e\r\n\u003c!--\r\n /* Font Definitions */\r\n @font-face\r\n\t{font-family:宋体;\r\n\tpanose-1:2 1 6 0 3 1 1 1 1 1;}\r\n@font-face\r\n\t{font-family:宋体;\r\n\tpanose-1:2 1 6 0 3 1 1 1 1 1;}\r\n@font-face\r\n\t{font-family:Calibri;\r\n\tpanose-1:2 15 5 2 2 2 4 3 2 4;}\r\n@font-face\r\n\t{font-family:\"\\@宋体\";\r\n\tpanose-1:2 1 6 0 3 1 1 1 1 1;}\r\n /* Style Definitions */\r\n p.MsoNormal, li.MsoNormal, div.MsoNormal\r\n\t{margin:0cm;\r\n\tmargin-bottom:.0001pt;\r\n\ttext-align:justify;\r\n\ttext-justify:inter-ideograph;\r\n\tfont-size:10.5pt;\r\n\tfont-family:\"Calibri\",\"sans-serif\";}\r\nh1\r\n\t{mso-style-link:\"标题 1 Char\";\r\n\tmargin-right:0cm;\r\n\tmargin-left:0cm;\r\n\tfont-size:24.0pt;\r\n\tfont-family:宋体;}\r\np.MsoHeader, li.MsoHeader, div.MsoHeader\r\n\t{mso-style-link:\"页眉 Char\";\r\n\tmargin:0cm;\r\n\tmargin-bottom:.0001pt;\r\n\ttext-align:center;\r\n\tlayout-grid-mode:char;\r\n\tborder:none;\r\n\tpadding:0cm;\r\n\tfont-size:9.0pt;\r\n\tfont-family:\"Calibri\",\"sans-serif\";}\r\np.MsoFooter, li.MsoFooter, div.MsoFooter\r\n\t{mso-style-link:\"页脚

...全文
713 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
shoppo0505 2018-01-21
  • 打赏
  • 举报
回复
可以参考这个帖子
shoppo0505 2018-01-21
  • 打赏
  • 举报
回复
是这个: http://blog.csdn.net/u011511086/article/details/72865006

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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