ASP to determine the actual length of string

Source: Internet
Author: User
Tags strlen trim

function Strlength (str)
On ERROR RESUME NEXT
Dim Winnt_chinese
Winnt_chinese = (len ("forum") =2)
If Winnt_chinese Then
Dim l,t,c
Dim i
L=len (str)
T=l
For I=1 to L
C=ASC (Mid (str,i,1))
If C<0 then c=c+65536
If c>255 Then
T=t+1
End If
Next
Strlength=t
Else
Strlength=len (str)
End If
If Err.number<>0 then Err.Clear
End Function
function strlen (str)
Dim p_len,xx
P_len=0
Strlen=0
If Trim (str) <> "" Then
P_len=len (Trim (str))
For Xx=1 to P_len
If ASC (Mid (str,xx,1)) <0 Then
Strlen=int (strlen) + 2
Else
Strlen=int (strlen) + 1
End If
Next
End If
End Function
function Cutstr (str,lennum)
Dim p_num
Dim i,x
If strlen (str) <=lennum Then
Cutstr=str
Else
P_num=0
X=0
Do, not p_num > Lennum-2
X=x+1
If ASC (Mid (str,x,1)) <0 Then
P_num=int (P_num) + 2
Else
P_num=int (p_num) + 1
End If
Cutstr=left (Trim (str), x) & "..."
Loop
End If
End Function
function Insertzero (M)
If Len (M) =1 Then
insertzero= "0" &m
Else
Insertzero=m
End If
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.