drti52047 2016-03-18 02:48
浏览 43
已采纳

在提供元数据后,页面上显示的数据库中的UTF代码仍然是UTF格式

I have an UTF code for single quotes inside my database, but when trying to display it on the page, it's still in UTF code for some reason, even though I provided the meta tags. What am I doing wrong?

In Database: '

On Page: '

<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  • 写回答

1条回答 默认 最新

  • dream07769 2016-03-18 06:18
    关注

    In the case of apostrophe or double quotes, it may be necessary to be able to include such characters without danger of closing an attribute. But you should be concerned about why the database has the data stored in this manner in the first place. If some script is doing the escaping, it may be mistakenly doing that twice. Double-escaping will not be harmful, but it may turn some harmless escapes added by users (e.g., if they want to use < or &) into these visible codes.

    Sometimes such escaping may be a sign that all special characters are being escaped (not just apostrophes) for the sake of security (e.g., to escape < into &lt; so that no tags can be added with user inputted data), but double-escaping (as in your example) is probably a sign that the input has been entered into the database incorrectly. If you convert &amp; back to &, this should at least not be a security problem for HTML though, but it could be a security problem for genuine XML.

    Also, FYI, the proper term instead of "UTF code" is Unicode numeric character references. "UTF-8", "UTF-16", etc. are different ways to encode abstract Unicode characters, but numeric character references provide a way to avoid characters getting corrupted in programs that do not properly support Unicode, and they also make visible some invisible, or difficult to see, characters.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据