From: selecter at spray dot se
Operating system: linux gentoo
PHP version: 5.0.0RC1
PHP Bug Type: SimpleXML related
Bug description: simpleXML and cyrillic bug
Description:
------------
Character coding mess...
index.php and example.xml are saved in koi8-r encoding
Reproduce code:
---------------
index.php:
<?php
include 'example.xml';
$xml = simplexml_load_string($xmlstr);
function open_linkset($num)
{
global $xml;
eval("foreach(\$xml->linkset[$num]->mylink as \$mylink)
{
generate_link(\$mylink->title, \$mylink->href);
}");
}
function generate_link($title, $href)
{
global $link;
$link[]='<a href="?'.$href.'&open='.$_GET[open].'">'.$title.'</a>';
}
function generate_linkbox()
{
global $xml, $link;
$i=0;
$array_size=sizeof($xml->linkset);
foreach($xml->linkset as $mylinkset)
{
echo '<a href="?open='.$i.'">'.$mylinkset->name.'</a>';
echo "<br>";
if(isset($link) && $_GET[open]==$i)
{
$k=0;
$link_array_size=sizeof($link);
foreach($link as $mylink)
{
echo " ".$link[$k];
if($link_array_size<>$k)echo "<br>";
$k++;
}
}
$i++;
}
}
if(isset($_GET[open]))
{
open_linkset($_GET[open]);
generate_linkbox();
}else{
generate_linkbox();
}
?>
example.xml:
<?php
$xmlstr = <<<XML
<?xml version='1.0' encoding='koi8-r' standalone='yes'?>
<linkbox>
<linkset>
<name>Главная</name>
<mylink>
<href>to=fotos</href>
<title>Fotos</title>
</mylink>
<mylink>
<href>to=art</href>
<title>Art</title>
</mylink>
</linkset>
<linkset>
<name>Discussion</name>
<mylink>
<href>to=forum</href>
<title>Forum</title>
</mylink>
<mylink>
<href>to=guestbook</href>
<title>Guestbook</title>
</mylink>
</linkset>
</linkbox>
XML;
?>
Expected result:
----------------
Executing index.php I expect to see 2 linksets:
Главная
Discussion
Actual result:
--------------
The actual result after executing index.php:
Главная
Discussion
--
Edit bug report at http://bugs.php.net/?id=27858&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=27858&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=27858&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=27858&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=27858&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=27858&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=27858&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=27858&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=27858&r=support
Expected behavior: http://bugs.php.net/fix.php?id=27858&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=27858&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=27858&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=27858&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27858&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=27858&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=27858&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=27858&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27858&r=float