Wordpress & A “Byte-Order Mark found in UTF-8 File” Warning
Posted in Web Design on 10/08/2008 12:12 pm by JasonAfter installing and tweaking my latest theme on a Wordpress installation, every time I would check validation I would receive the following wonderful little warning:
Warning Byte-Order Mark found in UTF-8 File.
The Unicode Byte-Order Mark (BOM) in UTF-8 encoded files is known to cause problems for some text editors and older browsers. You may want to consider avoiding its use until it is better supported.
Now, while technically validation still passes, me being the O.C.D. individual I am, had to fix this warning because it was driving me batty.
So, off I head to Google to research the issue before formulating a plan to fix it…
According to Wikipedia,
A byte-order mark (BOM) is the Unicode character at code point
U+FEFF(”zero-width no-break space”) when that character is used to denote the endianness of a string of UCS/Unicode characters encoded in UTF-16 or UTF-32. It is conventionally used as a marker to indicate that text is encoded in UTF-8, UTF-16 or UTF-32.
Upon further reading, Some encodings, such as UTF-16, need a BOM (Byte Order Mark) in order to work properly. UTF-8 is not one of them. However, some text editors add one anyway, so that they can more easily recognize the file as UTF-8.
Alright… Now I know where to start…
Basically, I had two options:
- Using Notepad ++ (or a similar application) to open each file in the template and change the encoding to UTF-8
- Using a hexadecimal editor, open each file and remove the first three blocks enumerated as “EF BB BF”
Just for the hell of it, I went with the 2nd option.
So, first thing I did was download all of the templates PHP files to temp folder on me desktop and fired up my trusty hex editor (I prefer XVI32 ). Opening each file in the editor I could immediately see what needed to be done:
As you can see from the first three blocks in the left hand pane, the hexadecimal “EF BB BF” for the BOM is present. In the right hand pane, you can see the resulting output in the file. Generally, you can only see this in a text editor that does not support BOM, or can be turned on/off manually.
So, to manually correct this in a UTF-8 document, all you have to do is delete those first three blocks, save the file, and reupload. One thing I did notice is that it had to be removed from not only the header.php file in the theme, but also the index.php, and footer.php file. I actually went through all of the PHP files in the theme that were set to UTF-8 and removed them just to be safe.






