#34730 [Opn->Bgs]: saveXML translates UTF-8 characters to entities
| From: | derick@php.net | Date: | Tue, 04 Oct 2005 12:53:12 +0000 |
| Subject: | #34730 [Opn->Bgs]: saveXML translates UTF-8 characters to entities | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-85992@lists.php.net to get a copy of this message | ||
ID: 34730
Updated by: derick@php.net
Reported By: pesmail2003 at seznam dot cz
-Status: Open
+Status: Bogus
Bug Type: DOM XML related
Operating System: Linux 2.6.10-5-i386
PHP Version: 5.0.5
New Comment:
You need to specify the charset encoding in your XML, like so:
<?php
$xmlData = <<<XMLCODE
<?xml version="1.0" encoding="utf8"?>
<test>"пÑиваÑе</test>
XMLCODE;
$dom = new DomDocument;
$dom->loadXML( $xmlData );
echo $dom->saveXML();
?>
Previous Comments:
------------------------------------------------------------------------
[2005-10-04 14:46:19] pesmail2003 at seznam dot cz
Description:
------------
saveXML function replaces UTF-8 characters to entities. If I have some
UTF-8 characters in my loaded XML file and want to save it with
saveXML, it replace everything to entities like this č ř
ž ýá í é I had to write my own saveXML in PHP
and it's really bad.
Reproduce code:
---------------
<?php
$xmlData = <<<XMLCODE
<?xml version="1.0" ?>
<test>"ìèøýáíé</test>
XMLCODE;
$dom = new DomDocument;
$dom->loadXML( $xmlData );
echo $dom->saveXML();
?>
Expected result:
----------------
<?xml version="1.0"?>
<test>"ìèøýáíé</test>
Actual result:
--------------
<?xml version="1.0"?>
<test>"ěščřžýáíé</test>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=34730&edit=1