Controls the length of the output string to distinguish between Chinese and English (ASP)

Source: Internet
Author: User
Tags strlen trim
Control | difference | string | string strvalue ("Please email notification if you do not fill out the registered email", 26)
Here 26 refers to 26 English letters, which are 13 Chinese characters.


function strlen (str)
Dim P_len
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 strvalue (str,lennum)
Dim p_num
Dim i
If strlen (str) <=lennum Then
Strvalue=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
Strvalue=left (Trim (str), x) & "..."
Loop
End If
End Function

Original address: http://7i24.com/asp/103260940232.htm



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.