How to detect malformed utf-8 string in PHP?

后端 未结 4 2233
时光取名叫无心
时光取名叫无心 2020-11-27 05:16

iconv function sometimes gives me an error:

Notice:
iconv() [function.iconv]:
Detected an incomplete multibyte character in input string in [...]
         


        
4条回答
  •  庸人自扰
    2020-11-27 05:40

    You could try using mb_detect_encoding to detect if you've got a different character set (than UTF-8) then mb_convert_encoding to convert to UTF-8 if required. It's more likely that people are giving you valid content in a different character set than giving you invalid UTF-8.

提交回复
热议问题