Working with GD ( imagettftext() ) and UTF-8 characters

前端 未结 2 555

Just for the record - my first question here but hopefully not my last input in the community. But that\'s not why I\'m here.

I\'m currently developing a simple syst

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-04 02:20

    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!

提交回复
热议问题