I have the following string:
$string = "★ This is some text ★";
I want to convert it to html entities:
$string = "★ This is some text ★";
The solution everyone is writing about:
htmlentities("★ This is some text ★", "UTF-8");
But htmlentities can't convert all unicodes to html entities. So it just gives me the same output as the input:
★ This is some text ★
I've also tried to combine this solution with both:
header('Content-Type: text/plain; charset=utf-8');
and:
mb_convert_encoding();
But this either prints and empty result, doesn't convert at all or wrongly converts the stars to:
Â
How to I convert ★ and all other unicode characters to the correct html entity?