Test line:
$s = "convert this: "; $s .= "–, —, †, ‡, •, ≤, ≥, μ, ₪, ©, ® y ™, ⅓, ⅔, ⅛, ⅜, ⅝, ⅞, ™, Ω, ℮, ∑, ⌂, ♀, ♂ "; $s .= "but, not convert ordinary characters to entities";
$encoded = mb_convert_encoding($s, 'HTML-ENTITIES', 'UTF-8');
If your input string is UTF-8, this should encode most of all into numeric entities.
Good htmlentities are not working properly. Fortunately, someone has hosted code on the php website that seems to correctly translate multibyte characters
ascii html (& #xxxx). https://github.com/hellonearthis/ascii2web