Edit report at https://bugs.php.net/bug.php?id=64912&edit=1
ID: 64912 Updated by: yohg...@php.net Reported by: alexander dot stehlik at gmail dot com Summary: Unexpected output when parsing PHP files containing NUL characters -Status: Open +Status: Feedback Type: Bug Package: mbstring related Operating System: Linux (Ubuntu and CentOS) PHP Version: 5.4.15 Block user comment: N Private report: N New Comment: With 5.4.16, I get $ php -n -d mbstring.internal_encoding=utf-8 test.php testTEST $ php -n -d zend.multibyte=on -d mbstring.internal_encoding=utf-8 test.php Fatal error: Could not convert the script from the detected encoding "UTF-16BE" to a compatible encoding in Unknown on line 0 test.php <?php echo "test^@TEST";?> where ^@ is actual null char. e.g. $ echo -e "<?php echo \"test\0TEST\";?>" > test.php With some Japanese, I got the same result. $ php -n -d mbstring.internal_encoding=utf-8 test.php æ¥æ¬èªãããããtestTEST $ php -n -d zend.multibyte=on -d mbstring.internal_encoding=utf-8 test.php Fatal error: Could not convert the script from the detected encoding "UTF-16BE" to a compatible encoding in Unknown on line 0 Are you using the exact same test script or using more complex script? Previous Comments: ------------------------------------------------------------------------ [2013-05-23 17:31:10] alexander dot stehlik at gmail dot com Description: ------------ When this setting is used: zend.multibyte = On and I parse a PHP file that contains a NUL character (this one here: http://en.wikipedia.org/wiki/Null_character) I get some weird output. When I do not use the mbstring.internal_encoding setting I get a lot of question marks (?). When I use mbstring.internal_encoding = utf-8 I get some characters that look like Chinese to me. Test script: --------------- <?php // I can not insert the NUL character here. // To put it in a PHP file you can use the console: // // echo -e "here is \0 null" >> test.php $var = 'here is <InsertNULCharacterHere> null'; ?> Expected result: ---------------- When I run the given example with php test.php I expect no output, even when this setting is active: zend.multibyte = On Actual result: -------------- With the setting zend.multibyte = On I get some weird output (depending on the configured internal encoding): With the setting mbstring.internal_encoding = utf-8 I get an output that looks like this: ã°¿ç¨çâ¶æ ²â½â§æ¡¥ç©â³æ¤ 湵汬â»à¨¿ã¸ Without the setting the output looks like this: ??????????? ????? ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=64912&edit=1