php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #32431 SimpleXML encoding
Submitted: 2005-03-23 17:54 UTC Modified: 2005-04-01 13:44 UTC
Votes:10
Avg. Score:4.5 ± 0.7
Reproduced:8 of 8 (100.0%)
Same Version:2 (25.0%)
Same OS:8 (100.0%)
From: maka3d at yahoo dot com dot br Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: 5.0.3 OS: any
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: maka3d at yahoo dot com dot br
New email:
PHP Version: OS:

 

 [2005-03-23 17:54 UTC] maka3d at yahoo dot com dot br
Description:
------------
SimpleXML store data internally as UTF-8, which is bad if you need iso-8859-1. A good solution is the same used by xml_parser_set_option. ex:
xml_parser_set_option($xp,XML_OPTION_TARGET_ENCODING,'iso-8859-1')

// This is what we have today
$sxml = simplexml_load_string($xmlstr);
//$sxml = simplexml_import_dom($dom);
var_dump($sxml->asXML()); // OK
echo utf8_decode($sxml->menu->historico);

$internalEncoding = 'iso-8859-1';
$sxml = simplexml_load_string($xmlstr, $internalEncoding);
//$sxml = simplexml_import_dom($dom);
var_dump($sxml->asXML()); // OK
echo $sxml->menu->historico; // now, no need of utf8_decode


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-23 18:04 UTC] derick@php.net
This will not be changed until we have proper unicode support. All XML extensions behave currently like this.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 17:01:34 2025 UTC