Remove non-utf8 characters from string

后端 未结 18 1729
心在旅途
心在旅途 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

    $text = iconv("UTF-8", "UTF-8//IGNORE", $text);
    

    This is what I am using. Seems to work pretty well. Taken from http://planetozh.com/blog/2005/01/remove-invalid-characters-in-utf-8/

提交回复
热议问题