How to check the charset of string?

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

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

7条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-04 09:27

    mb_detect_encoding($string); will return the actual character set of $string. mb_check_encoding($string, 'UTF-8'); will return TRUE if character set of $string is UTF-8 else FALSE

提交回复
热议问题