How to Judge Chinese and English characters in PHP
PHP judges that the basis of English is the asii value of the character, while the asii value of the character differs depending on the encoding. In order to write a PHP program to judge the English characters, we must first understand the Asii value range of Chinese English characters under each code:
1. GBK (gb2312/gb18030)
\x00-\xff GBK Double byte encoding range
\x20-\x7f ASCII
\xa1-\xff Chinese gb2312
\x80-\xff Chinese GBK
2. UTF-8 (Unicode)
\U4E00-\U9FA5 (English)
\x3130-\x318f (Korean
\XAC00-\XD7A3 (Korean)
\u0800-\u4e00 (Japanese)
New Document
$str = "Chinese";
Echo $str;
echo "";
if (Preg_match ("/^[". Chr (0XA1). " -". Chr (0xff)." +$/", $str)) {//can only be used in GB2312 cases
if (Preg_match ("/^[\x7f-\xff]+$/", $str)) {//compatible gb2312,utf-8
echo "Correct input";
} else {
echo "Error input";
}
?>
http://www.bkjia.com/PHPjc/847207.html www.bkjia.com true http://www.bkjia.com/PHPjc/847207.html techarticle How to judge English and Chinese characters in PHP is based on the asii value of the character, and the asii value of the character differs depending on the encoding. In order to be able to write the English characters to determine the PHP program, ...