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>یہاں تو کوئی ہ</div> <span>some more text <good></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 <good></span>;
i have used
html_entity_decode($html, ent_compat, 'utf-8');
but converts <
<
, >
>
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
Post a Comment