Note that there are some explanatory texts on larger screens.

plurals
  1. POThe Actual Unicode Characters automatically converted to Numeric values using DOMDocument->saveHTML()
    primarykey
    data
    text
    <p>I am using the following function to get the inner html of html string</p> <pre><code>function DOMinnerHTML($element) { $innerHTML = ""; $children = $element-&gt;childNodes; foreach ($children as $child) { $tmp_dom = new DOMDocument('1.0', 'UTF-8'); $tmp_dom-&gt;appendChild($tmp_dom-&gt;importNode($child, true)); $innerHTML .= trim($tmp_dom-&gt;saveHTML()); } return $innerHTML; } </code></pre> <p>my html string also contains unicode character. here is example of html string</p> <pre><code>$html = '&lt;div&gt;Thats True. Yes it is well defined آپ مجھے تم کہہ کر پکاریں&lt;/div&gt;'; </code></pre> <p>When I use the above function</p> <pre><code>$output = DOMinnerHTML($html); </code></pre> <p>the output is as below</p> <pre><code>$output = '&lt;div&gt;Thats True. Yes it is well defined &amp;#1705;&amp;#1746;&amp;#1748;&amp;#1587;&amp;#1604;&amp;#1591;&amp;#1575&lt;/div&gt;'; </code></pre> <p>the actual unicode characters converted to numeric values. </p> <p>I have debugged the code and found that in DOMinnerHTML function before the following line</p> <pre><code>$innerHTML .= trim($tmp_dom-&gt;saveHTML()); </code></pre> <p>if I echo </p> <pre><code>echo $tmp_dom-&gt;textContent; </code></pre> <p>It shows the actual unicode characters but after saving to <code>$innerHTML</code> it outputs the numeric symbols. Why it is doing that.</p> <p>Note: please don't suggest me html_entity_decode like functions to convert numeric symbols to real unicode characters because, I also have user formatted data in my html string, that I don't want to convert.</p> <p>Note: I have also tried by putting the </p> <pre><code>&lt;meta http-equiv="content-type" content="text/html; charset=utf-8"&gt; </code></pre> <p>before my html string but no difference.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload