#38323 [Opn]: Sections is not processed when parse_ini_file() which encoded in UTF-8 w/ BOM

From: Date: Fri, 04 Aug 2006 19:49:33 +0000
Subject: #38323 [Opn]: Sections is not processed when parse_ini_file() which encoded in UTF-8 w/ BOM
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-100363@lists.php.net to get a copy of this message
ID: 38323 Updated by: andrei@php.net Reported By: zybersup at yahoo dot com Status: Open Bug Type: Unknown/Other Function Operating System: Windows XP Professional PHP Version: 4.4.3 New Comment: Please provide access to the exact .ini file that is problematic. I could not reproduce this on PHP 4 or 5. Previous Comments: ------------------------------------------------------------------------ [2006-08-04 17:24:34] zybersup at yahoo dot com Script to reproduce the bug ============================ <? $dir = dirname(__FILE__) . '/'; $ascii = parse_ini_file($dir . 'test_ascii.ini', true); $utf8bom = parse_ini_file($dir . 'test_utf8bom.ini', true); $utf8 = parse_ini_file($dir . 'test_utf8.ini', true); print_r($ascii); print_r($utf8bom); print_r($utf8); ?> Unsatisfied Result =================== (Don't worry about the value, just check the difference of array structure) Array ( [Section1] => Array ( [Aval] => &#3607;&#3604;&#3626;&#3629;&#3610; &#3607;&#3604;&#3626;&#3629;&#3610; (Test Test) [Bval] => &#3652;&#3607;&#3618; ) [Section2] => Array ( [Cval] => Bar [Dval] => Foo ) ) Array ( [Aval] => &#3648;&#3608;—&#3648;&#3608;”&#3648;&#3608;&#3594;&#3648;&#3608;&#3597;&#3648;&#3608;&#65533; &#3648;&#3608;—&#3648;&#3608;”&#3648;&#3608;&#3594;&#3648;&#3608;&#3597;&#3648;&#3608;&#65533; (Test Test) [Bval] => &#3648;&#3609;&#65533;&#3648;&#3608;—&#3648;&#3608;&#3586; [Section2] => Array ( [Cval] => Bar [Dval] => Foo ) ) Array ( [Section1] => Array ( [Aval] => &#3648;&#3608;—&#3648;&#3608;”&#3648;&#3608;&#3594;&#3648;&#3608;&#3597;&#3648;&#3608;&#65533; &#3648;&#3608;—&#3648;&#3608;”&#3648;&#3608;&#3594;&#3648;&#3608;&#3597;&#3648;&#3608;&#65533; (Test Test) [Bval] => &#3648;&#3609;&#65533;&#3648;&#3608;—&#3648;&#3608;&#3586; ) [Section2] => Array ( [Cval] => Bar [Dval] => Foo ) ) Try testing a demo at http://www.theguru.co.th/zybersup/test_parse_ini.php (May not keep there more than 2 months) ------------------------------------------------------------------------ [2006-08-04 07:55:08] tony2001@php.net Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If possible, make the script source available online and provide an URL to it here. Try to avoid embedding huge scripts into the report. ------------------------------------------------------------------------ [2006-08-04 02:20:24] zybersup at yahoo dot com Forgot to add more detail that... I have tested files encoded in ASCII, UTF-8 w/ BOM and UTF-8 w/o BOM on both PHP4 and PHP5 (5.0.5) Found no problem with ASCII and UTF-8 w/o BOM. Only UTF-8 w/ BOM has problem. Also I found no problem with PHP 5.0.5. So that this problem should not caused by my INI file, I guess ;). ------------------------------------------------------------------------ [2006-08-04 02:15:57] zybersup at yahoo dot com Description: ------------ Call the function parse_ini_file() with INI file that written in UTF-8 with BOM. Set process_sections to TRUE. The result is an array of all value correctly parsed, but no section processed. (That means the result is not multi-dimentional array.) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=38323&edit=1

« previous php.bugs (#100363) next »