最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp 截取字符串函数,计算一汉字等于2个英文
时间:2010-04-23 编辑:简简单单 来源:一聚教程网
'str 要截取的字符串
'strlen 截取字数
'str2 截取字符串后要加的字符。如:...
function gotTopic(str,strlen,str2)
if str="" or isnull(str) then
gotTopic=""
exit function
end if
dim l,t,c, i
str=replace(replace(replace(replace(str," "," "),""",chr(34)),">",">"),"<","<")
l=len(str)
t=0
for i=1 to l
c=Abs(Asc(Mid(str,i,1)))
if c>255 then
t=t+2
else
t=t+1
end if
if t>cint(strlen) then
if str2<>"" then i=i-1
gotTopic=left(str,i-1) & str2
exit for
else
gotTopic=str
end if
next
gotTopic=replace(replace(replace(replace(gotTopic," "," "),chr(34),"""),">",">"),"<","<")
end function
这个函数可以过滤html来截取哦,就是html与汉字混合的他也可以只截取中文哦。
-
上一个: asp之自动闭合HTML/ubb标签函数
相关文章
- VBS 批量Ping的项目讲解 09-19
- 如何封装一个Ajax函数介绍 09-16
- ASP实现加法验证码方法 09-16
- ASP错误捕获的几种常规处理方法介绍 09-16
- ajax实现城市三级联动的代码介绍 09-16
- asp中获取日期为星期几的技巧 09-14