#46455 [Opn->Bgs]: htmlentities() does not use default_charset or setlocale values

From: Date: Sat, 01 Nov 2008 20:38:30 +0000
Subject: #46455 [Opn->Bgs]: htmlentities() does not use default_charset or setlocale values
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-1289@lists.php.net to get a copy of this message
ID: 46455 Updated by: jani@php.net -Summary: htmlentities does not use default_charset or setlocale values Reported By: hostmaster at uuism dot net -Status: Open +Status: Bogus Bug Type: *Languages/Translation Operating System: Fedora Core 4 PHP Version: 5.2CVS-2008-11-01 (snap) New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Previous Comments: ------------------------------------------------------------------------ [2008-11-01 17:16:57] hostmaster at uuism dot net Description: ------------ The function htmlentities() appears to ignore the default_charset value in the php.ini file or the INI section of test scripts. I can't find any indication in the PHP Manual that htmlentities() is supposed to use the value for default_charset. This problem produces failure in the following tests: htmlentities() test 10 (default_charset / cp1252) [ext/standard/tests/strings/htmlentities10.phpt] htmlentities() test 11 (default_charset / ISO-8859-15) [ext/standard/tests/strings/htmlentities11.phpt] htmlentities() test 13 (default_charset / EUC-JP) [ext/standard/tests/strings/htmlentities13.phpt] If I change the htmlentities() statement to htmlentities("special characters", ENT_QUOTES, 'string') where string is cp1252, ISO-8859-15, and ISO-8859-15, respectively, the tests pass. The same kind of problem occurs with htmlentities() after the setlocale() command. I can't find any indication in the PHP Manual that htmlentities() is supposed to use the value from the setlocale() command. This variation of the problem causes these tests to fail: htmlentities() test 2 (setlocale / fr_FR.ISO-8859-15) [ext/standard/tests/strings/htmlentities02.phpt] (warn: possibly braind ead libc) htmlentities() test 4 (setlocale / ja_JP.EUC-JP) [ext/standard/tests/strings/htmlentities04.phpt] (warn: possibly braindead l ibc) htmlentities() test 15 (setlocale / KOI8-R) [ext/standard/tests/strings/htmlentities15.phpt] (warn: possibly braindead libc) If I change the htmlentities() statement to htmlentities("special characters", ENT_QUOTES, 'string') where string is ISO-8859-15, If I change the htmlentities() statement to htmlentities("special characters", ENT_QUOTES, 'string') where string is cp1252, ISO-8859-15, and KOI8-R, respectively, the tests pass. Reproduce code: --------------- <?php $result = (bool)setlocale(LC_CTYPE, "fr_FR.ISO-8859-15", "fr_FR.ISO8859-15", 'fr_FR@euro'); if (!$result) { die("skip setlocale() failed\n"); } echo "warn possibly braindead libc\n"; ?> --INI-- output_handler= default_charset= mbstring.internal_encoding=none --FILE-- <?php setlocale(LC_CTYPE, "fr_FR.ISO-8859-15", "fr_FR.ISO8859-15", 'fr_FR@euro'); var_dump(htmlentities("\xbc\xbd\xbe", ENT_QUOTES, 'ISO-8859-15')); ?> Expected result: ---------------- string(20) "&OElig;&oelig;&Yuml;" Actual result: -------------- string(24) "&frac14;&frac12;&frac34;" ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=46455&edit=1

« previous php.doc.bugs (#1289) next »