<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>