Utf8 or utf8 BOM

Search with Ctrl + F Last updated: 2022-08-16

Today, we encountered the problem of JSON client parse error output by the server.

UTF-8 without BOM is the standard form. It is Microsoft's habit to place BOM in UTF-8 file.


There are three more bytes EF BB BF at the beginning of the BOM format, which is mainly used for identification coding. BOM should be unique to windows. Various unexpected problems will occur when making web pages. For example, an empty line is output, which affects the session or cookies function of PHP (header already sent error occurs), and may even cause the page to be scrambled (those three bytes affect the browser's processing of page coding). Therefore, it is always recommended to use BOM free coding.


Therefore, it is better to unify all the codes into UTF-8 without BOM. In particular, some clients on the server side do not support the standard utf8. Special processing is required to minimize the cost


Vscode on setting: Auto guess encoding
Nodepad + + re encodes utf8 BOM into UTF-8 (no BOM)