Problem with encoding when dumping xml file (domDocument)
Posted: Tue Jul 21, 2009 9:30 am
Hi,
I got a problem with the encoding of special characters like umlaut when dumping them to an xml-file. The problem occurs on dump_file. The dump_mem output is correctly encoded but dump_file outputs 䶼 instead of the umlauts. How can I get the file output to b e correct too? Below is the code, the dump_mem output and the dimp_file output.
Thank you for the help
Code:
dump_mem output:
dump_file output:
I got a problem with the encoding of special characters like umlaut when dumping them to an xml-file. The problem occurs on dump_file. The dump_mem output is correctly encoded but dump_file outputs 䶼 instead of the umlauts. How can I get the file output to b e correct too? Below is the code, the dump_mem output and the dimp_file output.
Thank you for the help
Code:
Code: Select all
header('Content-Type: text/xml');
$doc = domxml_new_doc("1.0");
$root = $doc->add_root("root");
$head = $root->new_child("head", "");
$head->new_child("title", "äöü");
echo $doc->dump_mem(true,"utf-8");
$doc->dump_file($_SERVER["DOCUMENT_ROOT"] ."/widget_feed/"."testumlaut.xml", false, true);
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<root>
<head><title>äöü</title></head>
</root>
dump_file output:
Code: Select all
<?xml version="1.0"?>
<root>
<head><title>䶼</title></head>
</root>