最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp截取中英文字符 程序
时间:2008-06-10 编辑:简简单单 来源:一聚教程网
下面是经过改良以后的函数,供楼主参考
调用方法不变
function Setlen(str,howlong)
if str="" then
leftstr=""
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>=howlong then
leftstr=left(str,i) & "..."
exit for
else
leftstr=str
end if
next
leftstr=replace(replace(replace(replace(leftstr," "," "),chr(34),"""),">",">"),"<","<")
end function
Dim length, llen, i, value
Dim tmp
tmp = str
If isNull(tmp) Then tmp = ""
length = Len(tmp)
llen = 0
For i = 1 To length
value = AscW(Mid(tmp, i, 1))
If value >= -127 AND value <= 127 Then
llen = llen + 1
Else
llen = llen + 2
End If
'debugPrint(Mid(tmp, i, 1) & ":" & value & "--" & llen)
If llen >= number-3 Then
CutStr = Left(tmp, i) & "..."
Exit Function
End If
Next
CutStr = tmp
End Function
-
上一个: 非法字符过滤函数
-
下一个: asp 获取内网的IP
相关文章
- VBS 批量Ping的项目讲解 09-19
- 如何封装一个Ajax函数介绍 09-16
- ASP实现加法验证码方法 09-16
- ASP错误捕获的几种常规处理方法介绍 09-16
- ajax实现城市三级联动的代码介绍 09-16
- asp中获取日期为星期几的技巧 09-14