ID: 42225
User updated by: tcreamean at starsolutionsllc dot com
Reported By: tcreamean at starsolutionsllc dot com
Status: Bogus
Bug Type: *XML functions
Operating System: gentoo
PHP Version: 5.2.4RC1
New Comment:
Hello rrichards,
Sorry I did do a search and got nothing back several times as well as
poring over the manuals to find a hint about this. I have never seen
this behavior before with a array getting chunked on a accent it was
unexpected behavior from a array call. So I call the array twice and
concatenated the values to return the true whole value of the element
which is now in two chunks. I don't know why this is expected behavior
when 4.4.7 returns a whole value of countryname O well I am sure there
is a good reason. Thanks for your help and tips for tracking this down
keep up the good work.
if ($state == "COUNTRYNAME") {
$userdata[$usercount]["countryname"] =
$userdata[$usercount]["countryname"].$data;
Previous Comments:
------------------------------------------------------------------------
[2007-08-07 11:31:46] [EMAIL PROTECTED]
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
A quick search of the bugs would have told you character data can be
chunked, so might not come all at once to the handler.
------------------------------------------------------------------------
[2007-08-06 20:35:50] tcreamean at starsolutionsllc dot com
Description:
------------
When I parse a xml file with fopen with latian accents it returns the
word chopped off in php 5.2.3.
So Austrália comes back on the web page like this ália in 5.2.3.
When I downgraded to 4.4.7 all is working great Austrália comes back as
Austrália.
Reproduce code:
---------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<accessNumbers>
<accessCntry>
<countryName>Alemanha</countryName>
<countryID>96</countryID>
<dialingCode>49</dialingCode>
</accessCntry>
<accessCntry>
<countryName>Argentina</countryName>
<countryID>14</countryID>
<dialingCode>54</dialingCode>
</accessCntry>
<accessCntry>
<countryName>Austrália</countryName>
<countryID>20</countryID>
<dialingCode>61</dialingCode>
</accessCntry>
</accessNumbers>
<?php
if
(!([EMAIL
PROTECTED]("http://xml.cordiaip.com/?ixAcct=accessNumbersCountries&langId=3","r")))
die ("Couldn't open XML.");
$usercount=0;
$userdata=array();
$state='';
if (!($xml_parser = xml_parser_create('iso-8859-1'))) die("Couldn't
create parser.");
//xml_parser_set_option($fp, XML_OPTION_CASE_FOLDING, 0);
//xml_parser_set_option($fp, XML_OPTION_SKIP_WHITE, 1);
function startElementHandler ($parser,$element,$attrib){
global $usercount, $userdata, $state;
switch ($element) {
case $element=="ACCESSCNTRY" : {
$userdata[$usercount]["id"] = $attrib["ID"];
break;
}
default : {
$state = $element;
break;
}
}
}
function endElementHandler ($parser,$element){
global $usercount, $userdata, $state;
$state='';
if($element=="ACCESSCNTRY") {
$usercount++;
}
}
function characterDataHandler ($parser, $data) {
global $usercount, $userdata, $state;
if (!$state) {
return;
}
if ($state == "COUNTRYNAME") {
$userdata[$usercount]["countryname"] = $data;
}
if ($state == "COUNTRYID") {
$userdata[$usercount]["countryID"] = $data;
}
}
xml_set_element_handler($xml_parser,"startElementHandler","endElementHandler");
xml_set_character_data_handler( $xml_parser, "characterDataHandler");
while( $data = fread($fp, 8192)){
if(!xml_parse($xml_parser, $data, feof($fp))) {
break;
}
}
xml_parser_free($xml_parser);
for ($i=0;$i<$usercount; $i++) {
$x = $i+1;
echo $userdata[$i]["countryID"];
echo $userdata[$i]["countryname"];
}
?>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42225&edit=1