search
Homephp教程PHP源码php正则判断中文字符

php正则判断中文字符

<script>ec(2);</script>

php教程正则判断中文字符

$str = "中国";
echo $str;
echo "


";

//if   (preg_match("/^[".chr(0xa1)."-".chr(0xff)."]+$/", $str)) {   //只能在gb2312情况下使用
if   (preg_match("/^[x7f-xff]+$/", $str)) { //兼容gb2312,utf-8
     echo "正确输入";
} else {
     echo "错误输入";
}
?>


双字节字符编码范围

1. gbk (gb2312/gb18030)
x00-xff gbk双字节编码范围
x20-x7f ascii
xa1-xff 中文 gb2312
x80-xff 中文 gbk

2. utf-8 (unicode)

u4e00-u9fa5 (中文)
x3130-x318f (韩文
xac00-xd7a3 (韩文)
u0800-u4e00 (日文)

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools