|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-08-11 13:26 UTC] derick@php.net
[2004-08-11 14:16 UTC] jon at hiveminds dot net
[2004-08-11 14:38 UTC] derick@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 18:00:01 2025 UTC |
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.