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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 30 06:01:29 2024 UTC