Home  >  Article  >  Backend Development  >  PHP 如何判断一个汉字是不是 UTF-8 编码

PHP 如何判断一个汉字是不是 UTF-8 编码

WBOY
WBOYOriginal
2016-06-06 20:21:491622browse

PHP 如何判断一个汉字是不是 UTF-8 编码

回复内容:

PHP 如何判断一个汉字是不是 UTF-8 编码

用mb_detect_encoding();

<code>$str = 'áéóú'; // 编码ISO-8859-1
mb_detect_encoding($str, 'UTF-8', true); // 判断结果false
</code>

汉字编码后还是汉字么?

mb_detect_encoding

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn