#40762 [NEW]: xml_parser failed to parse mixed coding file
| From: | forward at hongyu dot org | Date: | Thu, 08 Mar 2007 21:56:57 +0000 |
| Subject: | #40762 [NEW]: xml_parser failed to parse mixed coding file | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-110102@lists.php.net to get a copy of this message | ||
From: forward at hongyu dot org
Operating system: Linux and Windows
PHP version: 5.2.1
PHP Bug Type: *XML functions
Bug description: xml_parser failed to parse mixed coding file
Description:
------------
My RSS parser failed after I upgrade the PHP version on my server from 4.x
to 5.2. When I debugged the code, I found the error was caused by the
xml_parse() function's failure to parse the UTF-8 encoded RSS message,
which is originally converted from a GB18030 string.
The error message looks like:
"Warning: xml_parse() [function.xml-parse]: input conversion failed due to
input error, bytes 0x9B 0xE6 ..."
The orginal GB encoded string consists of Chinese characters, but I
converted it to UTF-8 coding using function iconv(). I can view the
converted string correctly on web browsers, which means that there is no
converting error. So the failure only comes from xml_parse() function, I
believe.
For your testing purpose, an example of the original GB18030 string can be
downloaded at http://www.la-chinese.com/forum/rss.php?f=19
Thanks!
Reproduce code:
---------------
// variable $gb contains the GB encoded string, e.g., from
// web address http://www.la-chinese.com/forum/rss.php?f=19
// variable $utf contains the UTF-8 string converted from
// the original GB encoded string
$urf = iconv('GB18030','UTF-8', $gb);
// function feed_start_end and feed_end_element etc. are from
// the package Magpierss http://magpierss.sourceforge.net/
xml_set_object( $parser, $this );
xml_set_element_handler($parser,
'feed_start_element', 'feed_end_element' );
xml_set_character_data_handler( $parser, 'feed_cdata' );
$status = xml_parse( $parser, $utf );
Expected result:
----------------
No error message.
Actual result:
--------------
Warning: xml_parse() [function.xml-parse]: input conversion failed due to
input error, bytes 0x9B 0xE6 ...
--
Edit bug report at http://bugs.php.net/?id=40762&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40762&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40762&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40762&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=40762&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=40762&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=40762&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=40762&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=40762&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=40762&r=support
Expected behavior: http://bugs.php.net/fix.php?id=40762&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=40762&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=40762&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=40762&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40762&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=40762&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=40762&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=40762&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=40762&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=40762&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=40762&r=mysqlcfg