How to judge whether a character is a _asp basis of Chinese characters in ASP

Source: Internet
Author: User
In the program design we often need to check whether the user input is correct, especially the name, address and so on is not the input of Chinese characters. So, how to judge a character is not Chinese? In fact, there are at least two ways of ASP
First, the direct conversion of a character to ASCII code, if it is in English, he should be 0-127 of the range, and the Chinese character is a relatively large number, so you can use the following code to determine:
If ABS (ASC (WHICHCHAR)) >127 Then
Response.Write Whichchar & "is a Chinese character"
Else
Response.Write Whichchar & "Not a Chinese character"
End If
Second, the Unicode coding range of Chinese characters is 4e00-9fa5, so using regular expression test can judge whether a Chinese character is Chinese character or not.
Set Regexpobj=new regexp
Regexpobj.pattern= "^[\u4e00-\u9fa5]+$"
Regcheck=regexpobj.test (Whichchar)
Set regexpobj=nothing
If Regcheck Then
Response.Write Whichchar & "is Chinese character"
Else
Resposne.write Whichchar & "not Chinese characters"
End If

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.