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...
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