ASP UTF-8 code to intercept and get the length function _ Application techniques

Source: Internet
Author: User
Tags abs
Copy Code code as follows:

'************************************
' Intercept literal length function, support UTF-8
' Input parameters:
' 1, text content
' 2, text maximum length
'************************************
Public Function Cut_title (Title,tlen)
Dim K,i,d,c
Dim ISTR
Dim Fortotal

If CDBL (Tlen) > 0 Then
K=0
D=strlen (Title)
Istr= ""
Fortotal = Len (Title)

For I=1 to Fortotal
C=abs (ASCW) (Mid (title,i,1))
If c>255 Then
K=k+2
Else
K=k+1
End If

Istr=istr&mid (title,i,1)

If CLng (k) >clng (Tlen) Then
Istr=istr "..."
Exit for
End If
Next

Cut_title=istr
Else
Cut_title= ""
End If
End Function

'*******************************
' Detect literal length function, support UTF-8
' Input parameters:
' 1, text content
'*******************************
Public Function StrLen (strText)
Dim K,i,c
Dim Fortotal

K=0
Fortotal = Len (StrText)

For I=1 to Fortotal
C=abs (ASCW) (Mid (strtext,i,1))
If c>255 Then
K=k+2
Else
K=k+1
End If
Next
Strlen=k

End Function

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.