ProgramDuring the design, we often need to check whether the user input is correct, especially the name, address, and so on. How can we determine whether a character is a Chinese character? There are at least two methods in ASP.
1. convert a character into an ascii code using ASC. If it is an English character, it should be in the range of 0-127, while the Chinese character is a relatively large number, so you can use the followingCodeTo judge:
If ABS (ASC (whichchar)> 127 then
Response. Write whichchar & "is a Chinese character"
Else
Response. Write whichchar & "not a Chinese character"
End if
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.
Set regexpobj = new Regexp
Regexpobj. pattern = "^ [/u4e00-/u9fa5] + $"
Regcheck = regexpobj. Test (whichchar)
Set regexpobj = nothing
If regcheck then
Response. Write whichchar & "is a Chinese character"
Else
Resposne. Write whichchar & "not Chinese character"
End if