Re: XML_Parser bug
| From: | Marius Toma | Date: | Thu, 23 Sep 2004 22:23:43 +0000 |
| Subject: | Re: XML_Parser bug | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-14624@lists.php.net to get a copy of this message | ||
Actually I found now in Pear.php in function _create()
and put manually the encoding type
for US-ASCII and ISO-8859-1 shows me ? character and for UTF-8
’ in place of ' (apostrophe character)
If you want this is the XML:
http://www.cpsc.gov/cpscpub/prerel/prerel.xml
so...
Regards,
Marius
"Marius Toma" <marius@pro-websolutions.com> wrote in message
news:20040923220639.13836.qmail@pb1.pair.com...
> 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