在PHP中检查unicode

Ori*_*ion 16 php unicode character-encoding

如何使用PHP检查字符是否是Unicode字符?

Ali*_*xel 27

实际上你甚至不需要mb_string扩展名:

if (strlen($string) != strlen(utf8_decode($string)))
{
    echo 'is unicode';
}
Run Code Online (Sandbox Code Playgroud)

并找到给定字符的代码点:

$ord = unpack('N', mb_convert_encoding($string, 'UCS-4BE', 'UTF-8'));

echo $ord[1];
Run Code Online (Sandbox Code Playgroud)


Sve*_*lov 5

你可以试试

mb_check_encoding($s,"UTF-8")
Run Code Online (Sandbox Code Playgroud)

链接