如何删除网页脚本中的\ ufeff字符? [英] How do I remove a \ufeff character in my webpage scripts?

查看:110
本文介绍了如何删除网页脚本中的\ ufeff字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的脚本中删除一个隐藏的零宽度换行符(U + FEFF)。它出现在的网页是 http://cynicode.co.uk (请注意,索引页面已经被修改过,并且是唯一一个在此刻正常工作的页面)。

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





关键点是< body> < ! - 5--> 。这个在盘旋时表明它是一个 \\\ 字符。问题是,当我浏览脚本时,没有这样的字符存在。



我使用PHP和HTML来构建这个页面, < ! - 4--> < ! - 5--> 包含以下内容。首先,在实际的索引页面上:

 <?php 
echo<! - 4- - >中;
echo< head>< meta charset ='utf-8'/>< link rel ='快捷方式图标'type ='image / ico'href ='。/ images / CyniCode.ico' >
< title> CyniCode :: Index< / title>
< meta name ='description'content ='Cynic's paradise!Cynical Home。'/>
< ; meta name ='author'content ='Cynical'/>
< meta name ='keywords'content ='Cynical; Blog; Code'/>
< link type ='text / css'rel ='stylesheet'href ='。/ css / mystyle.css'/>
< link rel ='快捷方式图标'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>
<脚本类型='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';

这是索引页面的参考,引用的page.php脚本是我的作弊工具,可以快速,干净地设置页面,但是......这两个注释之间有一点点差异

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

任何人都可以提供帮助,我们将非常感谢。作品直接复制和粘贴到我的脚本中。

解决方案

一些 .php files(可能是 ./ functions / page.php 包含 Byte Order Mark )如果您使用的是一些IDE ,检查此文件的编码属性,运气好的话就可以将其删除。


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


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)

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

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.

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
  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
  echo "<!--5-->";

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

解决方案

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.

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

这篇关于如何删除网页脚本中的\ ufeff字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆