|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-11-01 17:16 UTC] 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) "ŒœŸ"
Actual result:
--------------
string(24) "¼½¾"
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 04 23:00:01 2025 UTC |
Let me express this a different way. In my php.ini file, I have: default_charset = "iso-8859-15" My code is: <?php print ini_get('default_charset')."\n"; print htmlentities("\xbc\xbd\xbe", ENT_QUOTES, '')."\n"; ?> I expect this result: iso-8859-15 string(20) "ŒœŸ" My actual results are: iso-8859-15 string(24) "¼½¾" Why doesn't htmlentities("\xbc\xbd\xbe", ENT_QUOTES, '') use the value for default_charset as the third parameter? Thanks. Jim P.S. I also tried htmlentities("\xbc\xbd\xbe", ENT_QUOTES) and htmlentities("\xbc\xbd\xbe"). They produced the same results. I tried htmlentities("\xbc\xbd\xbe", ENT_QUOTES, ini_get('default_charset')) and it works.