如何删除网页脚本中的\ufeff字符?

时间:2021-09-08 11:17:27

I am trying to, simply put, remove a hidden zero-width-line-break character (U+FEFF) in my script. The webpage that it has appeared on is at http://cynicode.co.uk (Please note, the index page has been tinkered with and is the only one which functions properly at the moment)

我试着,简单地说,在我的脚本中删除一个隐藏的零宽度线断字符(U+FEFF)。它出现的网页是http://nic ode.co。英国(请注意,索引页面已被修改,是目前唯一一个正常运行的)

By looking at the html elements on the page, this shows up:

通过查看页面上的html元素,可以发现:

如何删除网页脚本中的\ufeff字符?

The key point being the red dot between < body > and < !--5-- >. This, when hovered over, shows that it is a \ufeff character. The problem is that, when I look through the script, there is no such character that exists.

重点是< body >和< !- 5——>之间的红点。这,当盘旋,显示它是一个\ufeff字符。问题是,当我查看脚本时,不存在这样的字符。

I am using PHP and HTML to construct this page, and the items between < !--4-- > and < !--5-- > consists of the following. Firstly, on the actual index page itself:

我正在使用PHP和HTML来构建这个页面,而< !- 4—>和< !- 5—>之间的条目包括以下内容。首先,在实际的索引页面本身:

<?php
  echo "<!--4-->";
  echo "<head><meta charset='utf-8' /><link rel='shortcut icon' type='image/ico' href='./images/CyniCode.ico'>
    <title>CyniCode :: Index</title>
    <meta name='description' content='The Cynic's paradise! Home of Cynical.' />
    <meta name='author' content='Cynical' />
    <meta name='keywords' content='Cynical;Blog;Code' />
    <link type='text/css' rel='stylesheet' href='./css/mystyle.css' />
    <link rel='shortcut icon' type='image/ico' href='./images/CyniCode.ico'>
    <link href='http://fonts.googleapis.com/css?family=Muli' rel='stylesheet' type='text/css' />
    <script type='text/javascript' src='http://static.proofiction.net/jquery/jquery-1.9.1.min.js'></script>
    <script type='text/javascript' src='http://static.proofiction.net/jquery/loginwait.js'></script>
    <script type='text/javascript' src='http://static.proofiction.net/jquery/googleAnalytics.js'></script>
    <script type='text/javascript' src='./http://static.proofiction.net/jquery/jquery.bxslider.js'></script>
    <script type='text/javascript' src='./http://static.proofiction.net/jquery/jquery.bxslider.min.js'></script>
    <script type='text/javascript' src='https://www.google.com/jsapi'></script>
    <script type='text/javascript'><!--
      google_ad_client = 'ca-pub-xxxxxxxxxxxx';
      /* BiggerNavBox */
      google_ad_slot = '3977705372';
      google_ad_width = 300;
      google_ad_height = 600;
      //-->
    </script>
    <script>
      (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
      })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

      ga('create', 'UA-xxxxxxxx-1', 'cynicode.co.uk');
      ga('send', 'pageview'); 
    </script>

    </head>";
  require_once './functions/page.php';

This constitutes for the Index page. The page.php script referenced is my cheat for setting the page up quickly and cleanly. However... there is a small remaining difference between the two comments on the page. This is the remaining difference between the two comments.

这构成了索引页。该页面。引用的php脚本是我快速和干净地设置页面的欺骗。然而……页面上的两个注释之间还有一个小的区别。这是这两个评论之间剩下的区别。

<?php
  echo "<!--5-->";

Any help that anyone can offer would be much appreciated. All code pieces were direct copy and pastes from my scripts.

任何人能提供的任何帮助都将不胜感激。所有的代码片段都是来自我的脚本的直接拷贝和粘贴。

2 个解决方案

#1


21  

Some of your .php files (probably ./functions/page.php contains Byte Order Mark. If you are using some IDE, check this file's encoding properties and with luck you will be able to remove it.

您的一些。php文件(可能是。/函数/页)。php包含字节顺序标记。如果您正在使用某些IDE,请检查这个文件的编码属性,幸运的是,您将能够删除它。

Edit If you use *nix, Elegant way to search for UTF-8 files with BOM? should help.

如果您使用*nix,使用BOM搜索UTF-8文件的优雅方式进行编辑?应该帮助。

#2


9  

Here is a solution to a similar issue: Extra BOM character in HTML invalidating DOCTYPE tag

这里有一个类似问题的解决方案:HTML中的额外BOM字符使DOCTYPE标记无效

Basically the source of the issue are PHP files encoded in UTF8 with BOM, encoding them in UTF-8 without BOM solves the issue.

问题的根源基本上是用带有BOM的UTF8编码的PHP文件,用没有BOM的UTF-8编码。

如何删除网页脚本中的\ufeff字符?

#1


21  

Some of your .php files (probably ./functions/page.php contains Byte Order Mark. If you are using some IDE, check this file's encoding properties and with luck you will be able to remove it.

您的一些。php文件(可能是。/函数/页)。php包含字节顺序标记。如果您正在使用某些IDE,请检查这个文件的编码属性,幸运的是,您将能够删除它。

Edit If you use *nix, Elegant way to search for UTF-8 files with BOM? should help.

如果您使用*nix,使用BOM搜索UTF-8文件的优雅方式进行编辑?应该帮助。

#2


9  

Here is a solution to a similar issue: Extra BOM character in HTML invalidating DOCTYPE tag

这里有一个类似问题的解决方案:HTML中的额外BOM字符使DOCTYPE标记无效

Basically the source of the issue are PHP files encoded in UTF8 with BOM, encoding them in UTF-8 without BOM solves the issue.

问题的根源基本上是用带有BOM的UTF8编码的PHP文件,用没有BOM的UTF-8编码。

如何删除网页脚本中的\ufeff字符?