ASP intercepts Chinese-English character program

Source: Internet
Author: User
Tags chr
In fact, this method to limit the number of words there are defects, that is, in the interception, English mixed words, English also intercepted by a word
The following is a modified function, for the landlord reference
The calling method does not change
function Setlen (Str,howlong)
If str= "" Then
Leftstr= ""
Exit function
End If
Dim l,t,c, I
Str=replace (replace (replace (str, "", ""), "", CHR), "&gt;", ">"), "&lt;", "<")
L=len (str)
T=0
For I=1 to L
C=abs (ASC (str,i,1))
If c>255 Then
T=t+2
Else
T=t+1
End If
If T>=howlong Then
Leftstr=left (str,i) & "..."
Exit For
Else
Leftstr=str
End If
Next
Leftstr=replace (replace (replace (LEFTSTR, "", ""), Chr (+), "" ")," > "," &gt; ")," < "," &lt; ")
End Function

Public Function cutstr (str, number)
Dim length, Llen, I, value
Dim tmp
TMP = str
If isNull (tmp) Then tmp = ""
Length = Len (TMP)
Llen = 0
For i = 1 to length
Value = ASCW (Mid (TMP, I, 1))
If value >= -127 and value <= 127 Then
Llen = Llen + 1
Else
Llen = Llen + 2
End If
' DebugPrint (Mid (TMP, I, 1) & ": & Value &"--"& Llen)
If Llen >= number-3 Then
Cutstr = Left (tmp, i) & "..."
Exit Function
End If
Next
CUTSTR = tmp
End Function
Related Article

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.