学院首页>网络编程>ASP>计算真实字符串的长度

计算真实字符串的长度

作者:AspToOn 来源:未知 添加时间:2006-5-21 10:26:16
 计算字符串的长度,以Byte为单位,每个汉字为:2,英文为:1
函数在下面,是方法是:
strvalue("AspToOn作室作")返回值为:13

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 
站内搜索