1. Use ASCII code to judge
In the ASCII code table, the English range is 0-127, while the Chinese characters are greater than 127. The specific code is as follows:
Copy the codeThe code is as follows:
string text = "Is it Chinese characters, ABC, Ke Leyi";
for (int i = 0; i < ; i++)
{
if ((int)text[i] > 127)
("is Chinese characters");
else
("Not Chinese characters");
}
2. Use UNICODE encoding range of Chinese characters to judge
The UNICODE encoding range of Chinese characters is 4e00-9fbb, the specific code is as follows:
Copy the codeThe code is as follows:
string text = "Is it a Chinese character, ABC,";
char[] c = ();
for (int i = 0; i < ;i++)
if (c[i] >= 0x4e00 && c[i] <= 0x9fbb)
("is Chinese characters");
else
("Not Chinese characters");
3. Use regular expressions to judge
Using regular expressions to judge the UNICODE encoding range of Chinese characters, the specific code is as follows:
Copy the codeThe code is as follows:
string text = "Is it a Chinese character, ABC,";
for (int i = 0; i < ; i++)
{
if ((text[i].ToString(), @"[\u4e00-\u9fbb]+{1}quot;))
("is Chinese characters");
else
("Not Chinese characters");
}