#38427 [Opn->Ver]: unicode causes xml_parser to misbehave

From: Date: Fri, 11 Aug 2006 12:19:21 +0000
Subject: #38427 [Opn->Ver]: unicode causes xml_parser to misbehave
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-100694@lists.php.net to get a copy of this message
ID: 38427 Updated by: tony2001@php.net Reported By: codje2 at lboro dot ac dot uk -Status: Open +Status: Verified Bug Type: XML related Operating System: OS X PHP Version: 5.1.4 Previous Comments: ------------------------------------------------------------------------ [2006-08-11 11:57:17] codje2 at lboro dot ac dot uk Description: ------------ When xml_parse_into_struct reaches a unicode character (i.e an umlaut) when in a CDATA array element.It will split the text across two elements the second starting with that character. Reproduce code: --------------- <?php header('Content-type: text/html; charset=utf-8'); $input=<<<END <p>söme p tag <b>söme text</b> a bit more öf the p täg</p> END; print "<html><body><pre><xmp>"; //either save this example in UTF-8 form, or enable the follwing line //$input=utf8_encode($input); $parser = xml_parser_create('utf-8'); xml_parse_into_struct($parser, $input, $vals, $index); print_r($vals); print "</xmp></pre></body></html>"; ?> Expected result: ---------------- Array ( [0] => Array ( [tag] => P [type] => open [level] => 1 [value] => söme p tag ) [1] => Array ( [tag] => B [type] => complete [level] => 2 [value] => söme text ) [2] => Array ( [tag] => P [value] => a bit more öf the p täg [type] => cdata [level] => 1 ) [4] => Array ( [tag] => P [type] => close [level] => 1 ) ) Actual result: -------------- Array ( [0] => Array ( [tag] => P [type] => open [level] => 1 [value] => söme p tag ) [1] => Array ( [tag] => B [type] => complete [level] => 2 [value] => söme text ) [2] => Array ( [tag] => P [value] => a bit more [type] => cdata [level] => 1 ) [3] => Array ( [tag] => P [value] => öf the p täg [type] => cdata [level] => 1 ) [4] => Array ( [tag] => P [type] => close [level] => 1 ) ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=38427&edit=1

« previous php.bugs (#100694) next »