files saved in UTF-8, PHP5 sends UTF-8 BOM ;(

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi All,

I'm using UTF-8 encoding for my PHP scripts, output is also UTF-8.

all files have UTF-8 BOM: 0xEF 0xBB 0xBF at the beginning

I have PHP Version 5.1.2 on WinNT and PHP 5.1.1 on Gentoo

given code:

if (PHP_OS == 'WINNT')
    header('Content-Type: text/plain; charset=UTF-8"');
    var_dump(setlocale(LC_ALL, 'polish_Poland'));
    echo mb_strtoupper("aesz", 'utf-8');
    // this won't work BOM was sent -> headers were sent
    header('Content-Type: text/plain; charset=UTF-8"');
    var_dump(setlocale(LC_ALL, 'pl_PL.utf8'));
    echo mb_strtoupper("aesz", 'utf-8');

the output is:


string(18) "Polish_Poland.1250"

Linux Gentoo:

Warning: Cannot modify header information - headers already sent by
(output started at /home/xh/public_html/test.php:1) in
/home/rr/public_html/test.php on line 25
string(10) "pl_PL.utf8" AESZ

mb_strtoupper works fine on both systems but what about
PHP complaining about UTF-8 BOM when trying to send headers on

on WinNT I have a newer version of PHP...
is this error showing up because on Gentoo I use older PHP5?

thanks in advance for any help

best regards

Re: files saved in UTF-8, PHP5 sends UTF-8 BOM ;(

Quoted text here. Click to load it


Andy Hassall :: :: :: disk and FTP usage analysis tool

Site Timeline