In programming, we often need to check whether the user input is correct, especially whether the name, address, etc. are the Chinese characters entered. So, how to determine whether a character is a Chinese character? In fact, there are at least two ways to do it in Asp
1. Turn a character directly into asc to ascii code. If it is in English, it should be in the range of 0-127, while Chinese characters are a relatively large number, so you can use the following code to judge:
ifabs(asc(whichchar))>127then
response.write whichchar& is a Chinese character
else
response.write whichchar& is not a Chinese character
endif
2. The unicode encoding range of Chinese characters is 4e00-9fa5, so you can use regular expression to determine whether a Chinese character is a Chinese character.
setregexpobj=newregexp
regexpobj.pattern=^[/u4e00-/u9fa5]+$
regcheck=regexpobj.test(whichchar)
setregexpobj=nothing
ifregcheckthen
response.write whichchar& is Chinese character
else
resposne.write whichchar& is not a Chinese character
endif