开发者

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');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜