I noticed that WordPress files use UNIX end-of-line and UTF-8 without BOM. Is this a standard that should be used? Is there anything else to pay attention to?

I noticed that Filezilla fails to transfer Macintosh end-of-line files properly to Windows or Linux servers. New line endings are missing. And sometimes they are doubled with different configuration. I’d like to avoid that if possible.

2 Answers
2

UNIX line endings (\n) and UTF-8 are just common code standards. As far as I can see, they are not even mentioned in the Coding Standards. Most (all?) core PHP files are just plain US-ASCII. Try to follow that path to keep your files as compatible as possible.

If you use UTF-8, add a line at the start of a PHP file with an Encoding Cookie or file variable:

<?php # -*- coding: utf-8 -*-

Many editors (Emacs, Vim, Sublime, Scite) will use that to set the proper encoding automatically.

I have also seen:

<?php # -*- coding: utf-8-unix -*-

But I am not sure how compatible it is.

Leave a Reply

Your email address will not be published. Required fields are marked *