文件头出现的BOM问题

问题描述:在使用EditPlus等文本编辑工具,在windows下修改编码格式为UTF-8的文档时,会在文件的开头阐产生<feff>的字符。

 

问题影响:用IE浏览页面时,顶部会出现一行空白,查看页面的DOM结构,会发现其中的<link><script>标签会被解析到<body>标签下,在IE下,<meta>标签页会被解析到<body>标签下。


问题原因:在Windows标准下的UTF-8编码文档,是以<feff>开头来标识的,成为BOM(Byte Order Mark,字节序标记)。
文档摘录:
Q: What is a BOM?
A: A byte order mark (BOM) consists of the character code U+FEFF at the beginning of a data stream, where it can be used as a signature defining the byte order and encoding form, primarily of unmarked plaintext files. Under some higher level protocols, use of a BOM may be mandatory (or prohibited) in the Unicode data stream defined in that protocol.


解决方案:
配置EditPlus,删除BOM:“工具->首选项->文件->UTF-8标识->总是删除签名”,对应的英文版EditPlus路径为“Tools->Preferences->Files->UTF-8 signature->Always remove signature”
改用其他编辑工具,推荐VIM
转换为ASCII格式

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值