php - Is there any solution for unicode numeric symbols conversion to actual characters -


i pull hairs on issue. if 1 has solution. have html string

$html = '<div id="main">what going on </div><div>&#1740;&#1729;&#1575;&#1722;  &#1578;&#1608; &#1705;&#1608;&#1574;&#1740; &#1729</div> <span>some more text &lt;good&gt;</span>; 

this mixed html string having html entities + english characters + numeric symbols of unicode characters. want convert numeric symbols of unicode characters actual unicode character values. there user formatting not want lose.

i want following output

$html = '<div id="main">what going on </div><div>‘۔سلطان محمود نے گاڑی روکتے ہوئے</div> <span>some more text &lt;good&gt;</span>; 

i have used

html_entity_decode($html, ent_compat, 'utf-8'); 

but converts &lt; < , &gt; > not want.

any other solution??

note: not asking unicode characters not being shown correctly on webpage, shown well. because webpage renders numeric symbols , shows real unicode characters. want actaul unicode characters @ of webpage too.

try using preg_preplace_callback html_entity_decode callback.

$decode_single_entity = function ($matches) {     return html_entity_decode($matches[0], ent_compat, 'utf-8'); }; $string = preg_replace_callback('/&#\d+;/', $decode_single_entity, $html); 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -