How to check the charset of string?

前端 未结 7 1729
心在旅途
心在旅途 2021-02-04 08:48

How do I check if the charset of a string is UTF8?

7条回答
  •  一个人的身影
    2021-02-04 09:32

    Don't reinvent the wheel. There is a builtin function for that task: mb_check_encoding().

    mb_check_encoding($string, 'UTF-8');
    

提交回复
热议问题