当前位置: 首页 > 图文教程 > 网络编程 > ASP > 截取实际长度字符串,并用空格替换

ASP
一个查ASP木马的小东东
eWebEditor:网站中的隐形炸弹
跨站脚本执行漏洞详解与防护
XSS测试语句大全
Mssql高级注入笔记II
在MsSql、Access两种数据库中插入记录后马上得到自动编号的ID值
asp存储过程使用大全
生成静态页大全[ASP/PHP/ASPX]
显示在线人数
ASP 类 Class入门
一个ACCESS数据库访问的类
ASP操作Excel技术总结
几个常用的ASP函数
如何编写一个ASP类
数组显示菜单效果
创建一个ASP通用分页类
利用Split函数进行多关键字检索
asp实现表格3列5行
一句话木马入侵EASYNEWS新闻管理系统
ASP编程实用20例

ASP 中的 截取实际长度字符串,并用空格替换


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 57 ::
收藏到网摘: n/a

function cutstr(thestr,strlen)
dim l,t,c
l=len(thestr)
t=0
for dxy=1 to l
c=Abs(asc(Mid(thestr,dxy,1)))
if c>255 then
t=t+2
else
t=t+1
end if
if t>=strlen then
thev=left(thestr,dxy)
exit for
else
bu=strlen-t
for bui=1 to bu
strbu=" "
strbuall=strbuall&strbu
next
thev=thestr&strbuall
strbu=""
strbuall=""
end if
next
cutstr=thev
end function

<%
'============================
'函数名w_cut(type,num)
'作用:字符串截取
'参数type,num
'type:字符串内容
'num:字符串被截取的长度
'=============================

Function w_cut(types,num)
dim ctypes,cnum,ci,tt,tc,cc
ctypes=types:cnum=int(num):w_cut="":tc=0:cc=0
for ci=1 to len(ctypes)
if cnum<0 then w_cut=w_cut&"...":exit for
tt=mid(ctypes,ci,1)
if int(asc(tt))>=0 then
w_cut=w_cut&tt
tc=tc+1:cc=cc+1
if tc=2 then
tc=0:cnum=cnum-1
end if
if cc>5 then cnum=cnum-1:cc=0
else
cnum=cnum-1
if cnum<=0 then w_cut=w_cut&"...":exit for
w_cut=w_cut&tt
end if
next
End Function

%>