For example, a Chinese character will only be counted as a byte, in typesetting, if all is Chinese characters, say, anyway, no difference, but if the string has been manipulated by Chinese characters and English letters, it is inconvenient, the following three functions can replace the ASP's own related functions.
There are also areas of attention, if used in a loop, because the invariant "I" is also a variable that is often used for loops, the value of "I" will change when the following function is executed, and if the same variable is used in the call to his loop, an unknown result is generated, please replace it with another variable name.
The following usage is the same as Len (), left (), and Right ().
Program code
Copy Code code as follows:
Function strlength (str)
Temp_str=len (str)
for I=1 to Temp_str
test_str= (Mid (str,i,1))
If Asc (test_str) >0 Then
strlength=strlength+1
Else
Strlength=strlengt H+2
End If
Next
End Function
function Strleft (str,l)
Temp_str=len (STR)
for I=1 T o temp_str
test_str= (Mid str,i,1)
Strleft=strleft&test_str
If Asc (test_str) >0 Then
Lens=le Ns+1
Else
lens=lens+2
End If
if Lens>=l Then Exit for
Next
End Function
function strright (str,l)
Temp_str=len (STR)
For i = temp_str to 1 step-1
test_str= (Mid (str,i,1))
Strright=test_str&strright
If Asc (test_str) >0 Then
lens=lens+1
Else
lens=lens+2
End I F
If lens>=l Then Exit for
Next
End Function