#39565 [Opn]: xmlparser and accentuated letters

From: Date: Fri, 17 Aug 2007 11:53:36 +0000
Subject: #39565 [Opn]: xmlparser and accentuated letters
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-116233@lists.php.net to get a copy of this message
 ID:               39565
 Updated by:       vrana@php.net
 Reported By:      sotiwin at freemail dot hu
 Status:           Open
-Bug Type:         Documentation problem
+Bug Type:         XML related
 Operating System: Windows XP
 PHP Version:      5.2.0
 New Comment:

This behavior is wrong - all character data should be passed at once.


Previous Comments:
------------------------------------------------------------------------

[2006-11-21 12:27:15] sotiwin at freemail dot hu

Really? How could I parse an xml with accented data? Can I get the
whole word in one piece?

------------------------------------------------------------------------

[2006-11-21 08:17:08] derick@php.net

This is expected behavior, although we should definitely document this
in a bit better way - changing it to a documentation problem.

------------------------------------------------------------------------

[2006-11-21 02:16:31] sotiwin at freemail dot hu

Description:
------------
I want to parse an xml, with accentuated letters, but the parser cuts
the characters before the first accentuated letter of each
'characterData'.

I use Wamp5 with php 5.1.6.

Reproduce code:
---------------
<meta http-equiv="Content-type" value="text/html; charset=ISO-8859-1"
/>
<?php
	function characterData($parser, $data)
	{
		  echo $data.'1';
	}
	$data='<?xml version="1.0"
encoding="ISO-8859-1"?><book>Exampleéá</book>';
	echo 'XML input:<br>'.$data;
	
	$xml_parser = xml_parser_create('ISO-8859-1');
	xml_parser_set_option($xml_parser,XML_OPTION_SKIP_WHITE,1);
	xml_set_character_data_handler($xml_parser,'characterData');
	
	echo '<br>Parsed data:<br>';
	if (!xml_parse($xml_parser, $data)) 
	{
		die(sprintf("XML error: %s at line %d",
            xml_error_string(xml_get_error_code($xml_parser)),
            xml_get_current_line_number($xml_parser)));	
						
	}
	xml_parser_free($xml_parser);
?>

Expected result:
----------------
characterData could have run only once.

XML input:
Exampleéá
Parsed data:
Exampleéá1


Actual result:
--------------
characterData could have runs twice.
XML input:
Exampleéá
Parsed data:
Example1éá1


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=39565&edit=1


Thread (4 messages)

« previous php.bugs (#116233) next »