From: jon at hiveminds dot net
Operating system: Windows 2000 / SP4
PHP version: 5.0.0
PHP Bug Type: Strings related
Bug description: htmlentities() failure
Description:
------------
This string function fails on the "�" character (and other Latin-2
characters).
Test:
echo htmlentities("Ket�ua");
Returns: Ket�ua
Reproduce code:
---------------
Affected code:
$value = htmlentities($value);
preg_match_all("/&([^;]*);/", $value, $matches);
$parts = preg_split("/&|;/", $value, -1, PREG_SPLIT_NO_EMPTY);
foreach($parts as $part)
$td->appendChild(
in_array($part, $matches[1])
? $doc->createEntityReference($part)
: $doc->createTextNode($part)
);
Point of failure: the string "Ket�ua"
Expected result:
----------------
Character should be converted to Š (upper) / š (lower) per
HTML spec (see special-1.ent listing).
Failing this, should it not be possible to create a TextNode containing
this character when specifying a Latin-2 or Unicode charset?
Actual result:
--------------
Function returns the literal "�" character with no conversion.
It is not possible to create a TextNode containing this character using
DOMDocument::createTextNode().
I have written a workaround which replaces the Lat-2 chars with their
entity equivalents using str_replace(), but even so PHP still issues
several warnings when sending output to the browser using
DOMDocument::saveHTML():
Warning: output conversion failed due to conv error in
O:\webs\mysqli\oop-multi-select-with-dom.php on line 172
Warning: Bytes: 0x92 0x49 0x76 0x6F in
O:\webs\mysqli\oop-multi-select-with-dom.php on line 172
Warning: xmlOutputBufferWrite: encoder error in
O:\webs\mysqli\oop-multi-select-with-dom.php on line 172
The correct entity (š) does get sent, but I have to suppress the
error with an "@", which I don't like doing.
--
Edit bug report at http://bugs.php.net/?id=29609&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=29609&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=29609&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=29609&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=29609&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=29609&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=29609&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=29609&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=29609&r=support
Expected behavior: http://bugs.php.net/fix.php?id=29609&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=29609&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=29609&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=29609&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29609&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=29609&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=29609&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=29609&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=29609&r=float