检查PHP中的unicode [英] Check unicode in PHP

查看:291
本文介绍了检查PHP中的unicode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How can I check whether a character is a Unicode character or not with PHP?

推荐答案

需要mb_string扩展:

Actually you don't even need the mb_string extension:

if (strlen($string) != strlen(utf8_decode($string)))
{
    echo 'is unicode';
}

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

And to find the code point of a given character:

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

echo $ord[1];

这篇关于检查PHP中的unicode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆