#38427 [Ver->Csd]: unicode causes xml_parser to misbehave
| From: | rrichards@php.net | Date: | Tue, 15 Aug 2006 22:49:54 +0000 |
| Subject: | #38427 [Ver->Csd]: unicode causes xml_parser to misbehave | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-100845@lists.php.net to get a copy of this message | ||
ID: 38427
Updated by: rrichards@php.net
Reported By: codje2 at lboro dot ac dot uk
-Status: Verified
+Status: Closed
Bug Type: XML related
Operating System: OS X
PHP Version: 5.1.4
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
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