From:             Bjorn dot Wiberg at its dot uu dot se
Operating system: IBM AIX 5.2.0.0 ML5
PHP version:      5.0.4
PHP Bug Type:     Unknown/Other Function
Bug description:  Leading UTF-8 byte order mark yields different character 
encodings in output

Description:
------------
When a PHP/PHTML file (a file getting parsed by PHP) contains a leading
UTF-8 Byte Order Mark (BOM), EF BB BF in hex, the character encoding of
the output varies.


Possibly relevant PHP configuration snippets from httpd.conf:

php_value default_charset none
php_value default_mimetype "text/html"
php_admin_value output_buffering 4096
php_admin_value output_handler none


PHP configuration flags (from config.nice):

CPPFLAGS='-I/usr/local/include' \
LDFLAGS='-L/lib -L/opt/freeware/lib -L/usr/local/lib' \
CC='/usr/local/bin/gcc' \
'./configure' \
'--enable-bcmath' \
'--enable-calendar' \
'--enable-dba' \
'--enable-dbase' \
'--enable-dbx' \
'--enable-debug' \
'--enable-dio' \
'--enable-exif' \
'--enable-embedded-mysqli' \
'--enable-filepro' \
'--enable-ftp' \
'--enable-gd-jis-conv' \
'--enable-gd-native-ttf' \
'--enable-mbstring' \
'--enable-memory-limit' \
'--enable-shmop' \
'--enable-soap' \
'--enable-sockets' \
'--enable-sysvmsg' \
'--enable-sysvsem' \
'--enable-sysvshm' \
'--enable-yp' \
'--enable-zend-multibyte' \
'--prefix=/apache/php' \
'--with-apxs2=/apache/bin/apxs' \
'--with-bz2' \
'--with-freetype-dir' \
'--with-gd' \
'--with-gdbm' \
'--with-gettext' \
'--with-inifile' \
'--with-jpeg-dir' \
'--with-ldap' \
'--with-libxml-dir' \
'--with-mime-magic' \
'--with-mysql=/usr/local/mysql' \
'--with-openssl=/opt/freeware' \
'--with-png-dir' \
'--with-tiff-dir' \
'--with-ttf' \
'--with-xpm-dir' \
'--with-zlib' \
'--with-zlib-dir' \
"$@"

Reproduce code:
---------------
Source code with leading BOM:
http://www.anst.uu.se/bwiberg/php/utf8_bug.php.txt

Corresponding page yielding varying result:
http://www.anst.uu.se/bwiberg/php/utf8_bug.php

(Use telnet or other "dumb" tool to dump the results; it appears that the
result varies by server process that handles the request. We're using the
Apache 2 prefork MPM.)

Example of incorrect result, here we get ISO-8859-1 encoded output:

http://www.anst.uu.se/bwiberg/php/utf8_bug_result1.txt


Expected result:
----------------
Example of correct result, here we get UTF-8 encoded output:

http://www.anst.uu.se/bwiberg/php/utf8_bug_result2.txt


Actual result:
--------------
Varies between the two examples. Make sure to close the connection in
between (or the same server process will serve your multiple requests).

Restarting the web server does not help.

Changing the PHP settings for default character set (default_charset) and
default MIME type (default_mimetype) does not help; I have tried all
combinations.

Turning off output buffering (php_admin_flag output_buffering off) does
not help.

-- 
Edit bug report at http://bugs.php.net/?id=33198&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=33198&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=33198&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=33198&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=33198&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=33198&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=33198&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=33198&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=33198&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=33198&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=33198&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=33198&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=33198&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=33198&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=33198&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=33198&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=33198&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=33198&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=33198&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=33198&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=33198&r=mysqlcfg

Reply via email to