One common problem – it seems – with Wordpress just plain acting funky on IIS is that occasionally, byte-order-marks get inserted into the UTF-8 PHP documents that make up the Wordpress code.
Sometimes these come in as part of templates and plugins, other times they just magically* appear.
If you’ve got Visual C# (or Visual C# express), here’s a little nugget of code you can use to strip them out. No warranties. No expressed suitability for a given purpose. Just free code I wrote. Free, crappy, one-off, single-purpose code. But it works. Compile it up, and run it, and watch it go.
I recommend running it in two passes:
- Generate a list of files to check using DIR /S *.* /B /A-D > out.cmd
- Modify that list to call BOMFix on each file (e.g. BOMFix c:\myfile\app.php ). Make a note of which files have a BOM mark
- Run it again, with /F as the second argument (e.g. BOMFix c:\myfile\app.php /F ). This will strip the BOM from the files.
- Throw your files back up onto the server.
And for your viewing pleasure, here’s the code:
*Yes, I know, not actually magically… but no-one seems to have root-caused it.
Simon Cooke is an occasional video game developer, ex-freelance journalist, screenwriter, film-maker, musician, and software engineer in Seattle, WA.
The views posted on this blog are his and his alone, and have no relation to anything he's working on, his employer, or anything else and are not an official statement of any kind by them (and barely even one by him most of the time).