Hi all.

This is my first post here on drupal.org.

Me and a few colleagues have been searching for solution, both on drupal.org and Google. If you have a link where this problem have been solved, please share it.

Our problem is that on our local development server ("dev") our themes looks good, but when we upload them to our production server ("prod") the UTF-8 BOM is messing them up. They make blank lines and spaces where there should be none. We've removed the BOMs and it seems like it doesn't matter.

The problem appears where we use include() and require(). Is there a workaround or another recommended way to include files?

We also think it might be a problem with the server configs. On the dev-server we use Archlinux (don't know the version, /etc/arch-release was empty) with lang = en_US.utf8 (echo $LANG). On the prod-server we use Red Hat Enterprise Linux Server release 5.2 with lang = en_US.

We have tried to edit the .htaccess-file by adding this line: AddDefaultCharset UTF-8.

We also use DirectAdmin to administer the prod-server.

We still have to be backwards compatible and not break our existing sites (about 600+), which are in ISO-8859-1.

Thank you for your time!

Comments

cog.rusty’s picture

The BOM marker must not be there. Have you found out at which point it being added? In your text editor? In your upload client? In the server?

Tarnaurion’s picture

Thank you for your time.

We have spent several hours going through all files again and removed the BOM markers and it seems it works correctly now.

We have several editors that we use. The designers mostly use HomeSite 5.5 (which hasn't been developed since 2003) but we considering to move to UltraEdit. I use PSPad 4.5.3. This mixed environment is maybe not very good.

cog.rusty’s picture

And what's worse, many of these editors probably have a setting for inserting a BOM or not (at least UltraEdit does).

vesapalmu’s picture

We just had a similar problem. This is an easy problem to fix.

First you need to find all files with BOMs. Just go to the root directory of your Drupal site and start searching. Check all .php and .inc files:
find . -name "*.php" | xargs grep -l $'\xEF\xBB\xBF'
find . -name "*.inc" | xargs grep -l $'\xEF\xBB\xBF'

These commands will list all files that have a BOM in them. To remove them just open each file in vim:
vim filename_with_bom_in_it.php

To actually remove the BOM use ":set nobomb" in vim and then just save and quit with ":wq". Repeat this for all files you found and the problem is solved.