#46455 [Bgs]: htmlentities() does not use default_charset or setlocale values
| From: | hostmaster at uuism dot net | Date: | Sat, 01 Nov 2008 22:13:12 +0000 |
| Subject: | #46455 [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-1290@lists.php.net to get a copy of this message | ||
ID: 46455
User updated by: hostmaster at uuism dot net
Reported By: hostmaster at uuism dot net
Status: Bogus
Bug Type: *Languages/Translation
Operating System: Fedora Core 4
PHP Version: 5.2CVS-2008-11-01 (snap)
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2008-11-01 20:38:29] jani@php.net
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
------------------------------------------------------------------------
[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) "ŒœŸ"
Actual result:
--------------
string(24) "¼½¾"
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=46455&edit=1