How to determine a string that needs to be UTF8 decoded
Is there a possibility that you 开发者_开发问答can check a string if it needs to be UTF8 decoded in PHP?
You can use mb_detect_encoding
to check if the string is already encoded in UTF-8:
mb_detect_encoding($str, 'UTF-8', true)
This returns false if the string is not valid UTF-8.
You can determine if the string is using UTF-8 encoding by using
mb_detect_encoding($str, 'UTF-8');
精彩评论