Re: PHP DOM saveHTML outputs entities

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



What about html_entity_decode?
http://www.php.net/html_entity_decode

No. It doesn't help in this case.

DOMDocument->saveHTML() method converts any non-ascii characters into entities.
For example, if the dom document has the text node value of:
	שלום
It converts the string to entities:
	שלום
Although the string is already in UTF-8. The DOMDocument is already initialized with version "1.0" and encoding "UTF-8", the php file is in UTF-8, the xml file is in UTF-8 and got <?xml version="1.0" encoding="UTF-8"?> header.

Example:
<?php
$dom = new DOMDocument('1.0','utf-8');
$dom->loadXML("<html><body>שלום</body></html>");
$output = $dom->saveHTML();
header("Content-Type: text/html; charset=UTF-8");
echo $output;
?>

-thanks

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux