"working with gd ( imagettftext() ) and utf-8 characters" Code Answer

5

As I continued my research I came up with an answer for my problem, this piece of code did it!

private function properText($text){
    $text = mb_convert_encoding($text, "HTML-ENTITIES", "UTF-8");
    $text = preg_replace('~^(&([a-zA-Z0-9]);)~',htmlentities('${1}'),$text);
    return($text); 
}

Now all the characters (and all the new ones I've seen) that troubled me are displayed correctly!

By Orr Levinger on November 21 2022

Answers related to “working with gd ( imagettftext() ) and utf-8 characters”

Only authorized users can answer the search term. Please sign in first, or register a free account.