#42225 [NEW]: XML Parser or array is not return characters back before a accent
| From: | tcreamean at starsolutionsllc dot com | Date: | Mon, 06 Aug 2007 20:35:51 +0000 |
| Subject: | #42225 [NEW]: XML Parser or array is not return characters back before a accent | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-115812@lists.php.net to get a copy of this message | ||
From: tcreamean at starsolutionsllc dot com
Operating system: gentoo
PHP version: 5.2.4RC1
PHP Bug Type: *XML functions
Bug description: XML Parser or array is not return characters back before a accent
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
(!($fp=@fopen("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 bug report at http://bugs.php.net/?id=42225&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=42225&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=42225&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=42225&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=42225&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=42225&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=42225&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=42225&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=42225&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=42225&r=support
Expected behavior: http://bugs.php.net/fix.php?id=42225&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=42225&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=42225&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=42225&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42225&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=42225&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=42225&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=42225&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=42225&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=42225&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=42225&r=mysqlcfg