Asp截取中文字符
作者:admin 日期:2013-09-21
ASP/Visual Basic代码
- Function GetStringLength(txt,length)
- dim i
- i=1
- y=0
- txt=trim(txt)
- for i=1 to len(txt)
- j=mid(txt,i,1)
- if asc(j)>=0 and asc(j)<=127 then '汉字外的其他符号,如:!@#,数字,大小写英文字母
- y=y+0.5
- else '汉字
- y=y+1
- end if
- if -int(-y) >= length then '截取长度
- txt = left(txt,i)
- exit for
- end if
- next
- GetStringLength=txt
- End Function
评论: 0 | 引用: 0 | 查看次数: 2883
发表评论
广告位