php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32498 starting with 5.x the XML extension returns data in different encoding
Submitted: 2005-03-30 11:05 UTC Modified: 2005-03-30 18:44 UTC
From: thies at thieso dot net Assigned:
Status: Not a bug Package: XML related
PHP Version: 5CVS-2005-03-30 (dev) OS: linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: thies at thieso dot net
New email:
PHP Version: OS:

 

 [2005-03-30 11:05 UTC] thies at thieso dot net
Description:
------------
see code:
php 4.x will return the data in 'ISO8859-1'
php 5.x will return data in 'UTF8'

this will break every single script that uses non-UTF8 encoded xml-files with the "old" xml extension (OK only if you use more than "US-ASCII" characters in the xml).

this BC break happened when we switched from expat to libxml.

sidenote: as php does not support UTF8 natively i think it makes little sense to make this the default return-encoding for any internal-function.

btw: if you pass the 'ISO-8859-1' to xml_parser_create the php5.x behavior is like php4.x.







Reproduce code:
---------------
<?php
$xml = '<?xml version="1.0" encoding="ISO8859-1"?><a>����</a>';
xml_parse_into_struct(xml_parser_create(), $xml, $v, $i);
echo $v[0]['value'];
?>

Expected result:
----------------
(can't paste cause of encoding)

Actual result:
--------------
(can't paste cause of encoding)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-30 18:44 UTC] chregu@php.net
This was discussed in 
http://bugs.php.net/bug.php?id=29711

It was accepted as a BC-break-we-can-live-with, exactly because of "if you pass the 'ISO-8859-1' to xml_parser_create the php5.x behavior is like php4.x.", so you can at least "fix" the script easily to run on both versions.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 16:01:38 2025 UTC