Re: XML_Parser bug

From: Date: Thu, 23 Sep 2004 22:07:23 +0000
Subject: Re: XML_Parser bug
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-14623@lists.php.net to get a copy of this message
I have the same problem with English content when I tried to parse an RSS All the ' and " characters are replaced with ? The problem is the encoding There is any way how can I change the encode type of a file in PHP, because I copied the RSS so I can do whatever I want I PHP there is a function: resource xml_parser_create ( [string encoding]) and you can choose the encoding type How can I do that from PEAR? thanks, Marius "Denis Gerasimov" <denis.gerasimov@vekos.ru> wrote in message news:200408271211.i7RCBeuE017720@setteh-mtc.relinfo.ru... > > Hello All, > > I use XML_Parser 1.2.0 (latest version). > The bug is that it doesn't work properly with Russian text (I think there > may be also problems with other languages different to English). > > Server configuration: > OS: Windows 2000 Professional SP4 > Web server: Apache 2.0.50 > PHP: PHP 5.0.1 > > I run the following piece of code: > > class Handler > { > > function startHandler($objParser, $strName, $arrAttrs) > { > printf('handle start tag: %s<br />', $strName); > print '<br>Attbibs: '; > print_r($arrAttrs); > } > > function endHandler($objParser, $strName) > { > printf('handle end tag: %s<br />', $strName); > } > > } > > $objParser = new XML_Parser(); > $objHandler = new Handler(); > > $objParser->setInputFile('Sample.xml'); > $objParser->setHandlerObj($objHandler); > $objParser->parse(); > > The result is: > > handle start tag: ADMININTERFACE > > Attbibs: Array ( ) handle start tag: TITLE > > ........ > > Attbibs: Array ( [CLASSNAME] => table ) handle start tag: DATACOLUMN > > Attbibs: Array ( [CAPTION] => ????????????? ) handle end tag: DATACOLUMN > handle start tag: DATACOLUMN > > Attbibs: Array ( [CAPTION] => ??? ) handle end tag: DATACOLUMN > handle start tag: DATACOLUMN > > Attbibs: Array ( [CAPTION] => ????????? ) handle end tag: DATACOLUMN > handle start tag: DATACOLUMN > > Attbibs: Array ( [CAPTION] => ????? ) handle end tag: DATACOLUMN > handle end tag: DATAGRID > handle start tag: DATAFORM > > ........ > > handle end tag: DATAFORM > handle end tag: ADMININTERFACE > > > As you can see all non-ASCII characters were replaced with '?'. > I tried to parse XML documents in both windows-1251 and UTF-8 encoding (with > correct "encoding" attribute) but got absolutely same result. > > Does anybody know why this happened? > Any help or hints will be greatly appreciated. > > Best regards, Denis Gerasimov > Outsourcing Services Manager, > VEKOS, Ltd. > www.vekos.ru

« previous php.pear.general (#14623) next »