Regular expression judgment for Chinese (automatic recognition of utf-8 & gbk encoding)
The following example program is a PHP regular expression program that correctly matches utf8 or gbk Chinese, and can accurately obtain the recognition of Chinese characters in different encoding conditions.
gbk:
preg_match("/^[".chr( 0xa1)."-".chr(0xff)."a-za-z0-9_] $/",$str); //gb2312 Chinese character alphanumeric underline regular expression
http://www.bkjia.com/PHPjc/486134.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/486134.htmlTechArticleRegular judgment of Chinese (automatic recognition of utf-8 gbk encoding) The following example program is a php that correctly matches utf8 Or gbk Chinese regular expression program, which can accurately obtain the Chinese characters of different encoding situations...