前一段时间写PHP,经常在解析文件之前就要对数据进行处理判断,并以header()的方式进行页面跳转.然而后来将文件放到 linux 服务器时常碰到header()解析出错的情况,而在 windows 开发环境中本地调试无任何问题.后来发现是文件编码格式的原因,转换成以UTF-8无BOM编码格式的文件就不会报错了. 附上BOM的解释:https://en.wikipedia.org/wiki/Byte_order_mark 以及知乎上的讨论:「带 BOM 的 UTF-8」和「无 BOM 的 UT
In order to omit the byte order mark (BOM), your stream must use a custom instance of UTF8Encoding instead of the default System.Text.Encoding.UTF8: 1.Call the UTF8Encoding constructor with False for the encoderShouldEmitUTF8Identifier parameter. 2.P
VS的编译器对Unicode源代码支持如下: UTF-16 little endian with or without byte order mark (BOM). UTF-16 big endian with or without BOM. UTF-8 with BOM . vs2010 编译utf-8格式的代码总报错 带签名也就是带 BOM 信息,不带签名就是不带 BOM. BOM,即 Byte Order Mark,也即字节流标记,它是用来让应用程序识别所用的编码的.UTF-8 的 BOM