ASP-supported intercept string functions in Chinese and English

Source: Internet
Author: User


<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title>asp supports intercepting string functions in Chinese and English </title>

<body>
<%
' txt = ' string to be processed ', length = number, length is the number of characters that need to be preserved, and 1 characters are 2 characters.

Function Cutstr (txt,length)
Txt=trim (TXT)
x = Len (TXT)
y = 0
If x >= 1 Then
For II = 1 to X
If ASC (Mid (txt,ii,1)) < 0 or ASC (Mid (txt,ii,1)) >255 Then ' If it is Chinese
y = y + 2
Else
y = y + 1
End If
If y >= Length Then
txt = left (trim (TXT), ii) & "..." ' Long string limit
Exit for
End If
Next
CUTSTR = txt
If x > Length Then cutstr = txt & "..."
Else
Cutstr = ""
End If
End Function


%>

<form name= "Form1" method= "Post" action= "" >
<label>
<input type= "text" name= "charstring" >
</label>
<label>
<input type= "Submit" name= "Submission" value= "submitted" >
</label>
</form>
<%
If request. Form ("charstring") Then
Response. Write Cutstr (Request. Form ("charstring"), 10
End If
%>


</body>

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.