How to convert multiple multibyte characters to its numeric html object using PHP?

Test line:

$s = "convert this: ";
$s .= "–, —, †, ‡, •, ≤, ≥, μ, ₪, ©, ® y ™, ⅓, ⅔, ⅛, ⅜, ⅝, ⅞, ™, Ω, ℮, ∑, ⌂, ♀, ♂ ";
$s .= "but, not convert ordinary characters to entities";
+2
source share
3 answers
$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.

+11
source

Good htmlentities are not working properly. Fortunately, someone has hosted code on the php website that seems to correctly translate multibyte characters

0
source
0

All Articles