ID:               42225
 Updated by:       [EMAIL PROTECTED]
 Reported By:      tcreamean at starsolutionsllc dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         *XML functions
 Operating System: gentoo
 PHP Version:      5.2.4RC1
 New Comment:

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.


Previous Comments:
------------------------------------------------------------------------

[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

Reply via email to