Remove non-utf8 characters from string

后端 未结 18 1472
心在旅途
心在旅途 2020-11-22 11:56

Im having a problem with removing non-utf8 characters from string, which are not displaying properly. Characters are like this 0x97 0x61 0x6C 0x6F (hex representation)

18条回答
  •  花落未央
    2020-11-22 12:39

    The text may contain non-utf8 character. Try to do first:

    $nonutf8 = mb_convert_encoding($nonutf8 , 'UTF-8', 'UTF-8');
    

    You can read more about it here: http://php.net/manual/en/function.mb-convert-encoding.phpnews

提交回复
热议问题