开发者

How to determine a string that needs to be UTF8 decoded

开发者 https://www.devze.com 2023-03-24 09:26 出处:网络
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:

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

精彩评论

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