I have two sites I'm developing (in PHP). They are using identical code to provide an XLS export (using PEAR excel) and they are running on the same local server. To rule out a problem with the actual data in the xls, I am just outputting a file with no data for now.
When I export from site A and save the file it's reported as 'ANSI' encoded within Notepad++. This file opens correctly in Excel.
When I export from site B, the file is reported as 'UTF-8' encoded, the file won't open in Excel. If I convert the file to ANSI or UTF-8 without BOM in Textpad++, it opens just fine in Excel.
The same encoding difference is present between site A and B when I save an arbitrary page on the site, so I think it may be more fundamental than just how the Excel file is being generated (same encoding when exporting CSV/ODS formats). I've compared the http headers between site A and B during the export, they are functionally identical. Explicitly adding Charset=ISO-8859-1 to the header makes no difference. The apache virtual hosts are also functionally identical between sites. Both sites are using identical character encodings in their databases (but since I'm not exporting any data right now, this is irrelevant).
What else could be causing this which I haven't accounted for?
Thanks!
UPDATE
The excel generation is a red herring, I've removed all of that and simply outputting the download header and a test string. When saved, the file is still encoded differently between sites. The code which generates the download file seems identical when I diff the various files...
I haven't been able to repeat the problem by creating a simplified test case. When I tried, both sites output files which are saved as ANSI - I don't understand what else could be going on.
the ANSI "mode" just uses the language table you have on your system to save data; you cannot be sure the saved document will be visible to others.
the UTF-8 without BOM means utf8 but without appending some strange utf characters (2 or 3 i think at the top of file), probably causing excel a headache.
Im going always with without bom approach if im thinking i18n