微信公众平台 php自动回复时中文乱码--珍爱生命,远离 BOM
Unicode是唯一的,但Unicode的编码方式不是唯一的。编码方式可能是唯一的,但大端小端在前还不一定是唯一的。光说打开一个“Unicode”文件,其实不太容易做。 BOM就是把一个Unicode保留字符UFEFF,按照文件存储者的编码方式编码后,塞到文件内容的最前边。这
Unicode是唯一的,但Unicode的编码方式不是唯一的。编码方式可能是唯一的,但大端小端在前还不一定是唯一的。光说打开一个“Unicode”文件,其实不太容易做。
BOM就是把一个Unicode保留字符U+FEFF,按照文件存储者的编码方式编码后,塞到文件内容的最前边。这样用不同的Unicode编码去解析文件头,就可以得知文件的编码方式和大小端顺序。结果就是文件头部多出来了两三个字节。
有了BOM所有的程序都必须为BOM作出修改,这无疑是一个“大折腾”的行为。所以一般不认为BOM是个好主意。BOM引发的问题,我能想起来两个:
- PHP无法指定header(因为有BOM相当于开启输出)
- UNIX可执行脚本的Shabang标记(
#!
)不能识读
任何时候都采用无BOM的UTF-8编码的Unicode,绝对是一个引发麻烦最少的最实用策略。UTF-8是Unicode的最佳实践,没有之一。
必须指出的是,何弃疗的微软经常做出非要BOM不可的行为,最典型的例子就是那个记事本(存盘就加BOM)。所以任何时候,都千万别偷懒用记事本编辑PHP。华语骄傲Notepad++是Windows下的不二之选。
永远不要忘记:微软是技术落后,并且只会对超过自己的开源界冷嘲热讽,从不肯真正改正自己问题的业界毒瘤。话下的狠了点,不过就算没到这程度,也差不了多少。从一点一滴开始远离微软,让生活变得轻松些。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Dreamweaver CS6
Visual web development tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment