0
4

1 回答 1

2

Simple: Notepad, Wordpad and Word are all Microsoft products which notoriously suck with encodings expect UTF-8 encoded files to begin with a BOM. If you don't include the BOM, they do not recognize the encoding correctly and misinterpret the file.

It is not typically recommended to add a BOM to UTF-8 encoded files, only the Microsoft universe seems to require/prefer it. You need to decide which is worse: possibly introduce problems by including a BOM or having to somehow manually open the file in Word/Note(-pad) with the right encoding.

A BOM in PHP is simply this:

$bom = "\xEF\xBB\xBF";

Prepend it to your file.

于 2012-06-21T14:39:12.617 回答