How to prevent showing the diamond question mark symbol, even using mb_substr and utf-8

前端 未结 3 1192
梦毁少年i
梦毁少年i 2021-02-04 17:55

I have read some other questions, tried the answers but got no result at the end. What I get is for example this

Μήπως θα έπρεπε να � ...

and I

3条回答
  •  [愿得一人]
    2021-02-04 18:15

    Have you tried using these seemingly redundant multibyte safe string functions which are not in the php core?

    http://code.google.com/p/mbfunctions/

    It appears they offer an mb_strip_tags() function like such:

    if (! function_exists('mb_strip_tags'))
    {
       function mb_strip_tags($document,$repl = ''){
          $search = array('@]*?>.*?@si',  // Strip out javascript
                         '@<[\/\!]*?[^<>]*?>@si',            // Strip out HTML tags
                         '@]*?>.*?@siU',    // Strip style tags properly
                         '@@'         // Strip multi-line comments including CDATA
          );
          $text = mb_preg_replace($search, $repl, $document);
          return $text;
       }
    }
    

提交回复
热议问题