清除不可见字符的源代码文件 [英] Clean source code files of invisible characters

查看:133
本文介绍了清除不可见字符的源代码文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的问题:在我的HTML / PHP代码中有一个隐藏的,看不见的字符,我似乎无法摆脱。通过从Firebug中复制它并转换它,我将其标识为& #xFEFF; 或零宽度不间断空格。它在我的网站中显示为非空文本节点,并导致严重的布局问题。

I have a bizarre problem: Somewhere in my HTML/PHP code there's a hidden, invisible character that I can't seem to get rid of. By copying it from Firebug and converting it I identified it as  or 'Zero width no-break space'. It shows up as non-empty text node in my website and is causing a serious layout problem.

问题是,我无法摆脱它。我不能看到它在我的文件,即使当不可见的(d'uh)。我似乎找不到它,没有搜索工具似乎拾起它。

The problem is, I can't get rid of it. I can't see it in my files even when turning Invisibles on (d'uh). I can't seem to find it, no search tool seems to pick up on it. I rewrote my code around where it could be, but it seems to be somewhere deeper in one of the framework files.

任何好的工具,通过charcode跨文件查找字符,或者这样的东西? (Mac OS X)

Any good tools to find characters by charcode across files or something like that? (Mac OS X)

推荐答案

在编辑器中没有获取字符,编辑。 #FEFF或#FFFE是所谓的字节顺序标记。他们是一个微软的发明,在一个Unicode文件,其中存储多字节字符的顺序告诉。

You don't get the character in the editor, because you can't find it in text editors. #FEFF or #FFFE are so-called byte-order marks. They are a Microsoft invention to tell in a Unicode file, in which order multi-byte characters are stored.

要摆脱它,告诉你的编辑器保存文件作为ANSI / ISO-8859或Unicode (不含BOM)。如果你的编辑器不能这样做,你将不得不切换编辑器(可悲的是)或使用某种截断工具,例如,十六进制编辑器,让你看到如何文件真的看起来。

To get rid of it, tell your editor to save the file either as ANSI/ISO-8859 or as Unicode without BOM. If your editor can't do so, you'll either have to switch editors (sadly) or use some kind of truncation tool like, e.g., a hex editor that allows you to see how the file really looks.

在googleing,看来,TextWrangler有一个UTF-8,没有BOM模式。否则,如果你对终端很舒服,可以使用Vim:

On googleing, it seems, that TextWrangler has a "UTF-8, no BOM" mode. Otherwise, if you're comfortable with the terminal, you can use Vim:

:set nobomb

并保存文件。 Presto!

and save the file. Presto!

字符始终是文本文件中的第一

The characters are always the very first in a text file. Editors with support for the BOM will not, as I mentioned, show it to you at all.

干杯,

这篇关于清除不可见字符的源代码文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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