PHP determines Chinese and English characters (one more)
Release: 2016-07-25 09:11:02
Original
1018 people have browsed it
I seem to remember that I posted one before, written by myself. Today’s one is online and comes from:
http://www.cnblogs.com/zcy_soft/archive/2010/12/13/1904791.html
- /* There is actually a lot of knowledge involved in judging Chinese. The underlying internal encoding involves various differences in utf-8, gbk, and gb13800. I once studied the problem of how to distinguish what character a character is. There are too many related details.
-
- Today I made a PHP code to determine Chinese. I hope it can be helpful to friends who are studying Chinese judgment. */
- New Document
- < ;META http-equiv="Content-Type" content="text/html; charset=utf-8">
- $str = "China";
- echo $str;
- echo "
";
- //if (preg_match("/^[".chr(0xa1)."-".chr(0xff)."]+$/", $str) ) { //Can only be used under GB2312
- if (preg_match("/^[x7f-xff]+$/", $str)) { //Compatible with gb2312, utf-8
- echo "Correct input";
- } else {
- echo "Wrong input";
- }
- ?>
- /*
- Encoding table
- Double-byte character encoding range
- 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 (Chinese)
- x3130-x318F (Korean
- xAC00-xD7A3 (Korean)
- u0800-u4e00 (Japanese)*/
Copy code
|
Statement of this Website
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
Latest Articles by Author
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31