验证错误:在UTF-8文件中找到了字节顺序标记 [英] Validation error: Byte-Order Mark found in UTF-8 File

查看:148
本文介绍了验证错误:在UTF-8文件中找到了字节顺序标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个网站上工作,并在Firefox上显示它很好,在IE上我遇到了很多问题。我使用了w3c验证程序,并且发现了很多奇怪的错误。



以下是网站链接: http://misenplacecatering.it/



第一个验证错误,我认为最相关的是:

 在UTF-8文件中找到的字节顺序标记。已知UTF-8编码文件中的Unicode字节顺序标记(BOM)会导致某些文本编辑器和旧版浏览器出现问题。您可能需要考虑避免使用它,直到它得到更好的支持。 

 第1行,第1列:发现没有看到文档类型的非空格字符。预计<!DOCTYPE html> ;. 



我读过其他线程关于这个问题,所以我试图用不同的编辑器打开文件(反正我总是使用Vim),但是在doctype定义之前我没有看到任何空间或其他东西。我甚至使用记事本++,并使用一个选项来删除bom,但没有。



任何建议吗?

无论如何, 如果使用notepad ++,请使用转换为不带BOM的UTF-8。 如果您使用的是PHP,请确保任何包含的/必需的文件以ascii或UTF文件格式存在,而不使用BOM,因为php不会非ASCII格式地处理非ascii文件。 好(这一次让我头痛一次)



如果你不需要utf字符,你可以尝试把你的文件转换为ascii



放在< meta charset>上尝试在引号中写入值

I'm working on a website and while displaying it on Firefox is fine, on IE I've got a lot of problems. I used the w3c validator and I got a lot of strange errors.

Here's the link to the website: http://misenplacecatering.it/

The first validation error, I think the most relevant, is this:

Byte-Order Mark found in UTF-8 File. The Unicode Byte-Order Mark (BOM) in UTF-8 encoded files is known to cause problems for some text editors and older browsers. You may want to consider avoiding its use until it is better supported. 

and

Line 1, Column 1: Non-space characters found without seeing a doctype first. Expected <!DOCTYPE html>.

I've read other threads about this issue so I tried to open the file with different editors (I always use Vim, anyway), but I don't see any space or anything else before the doctype definition. I even used notepad++ and used an option to remove bom, but nothing.

Any suggestions?

Anyway,

解决方案

if using notepad++, use Convert to UTF-8 without BOM.

if you are using php, make sure that any included/required file is in either in ascii or UTF without BOM, as php doesn't handle non-ascii file very good (this one gave me a headache once)

you could try converting your files to ascii, if you don't need utf characters

on your <meta charset > try writing the value within quotes

这篇关于验证错误:在UTF-8文件中找到了字节顺序标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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