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

ASP
浅谈 ASP 模板技术之参数传递
九种防MDB数据库被下载的方法
如何采集静态文章系统
提供几个关于采集的函数(ASP)
ASP小偷(远程数据获取)程序的入门教程
远程图片自动按文件夹上传到服务器-默飞出品
纯编码实现Access数据库的建立或压缩
同一个帐号不能同时登陆的问题
跨越fso、wsh、 application写文件
用ASP设计购物推车
ASP中Web页面间的数据传递方式
ASP得到文件的大小类型最后修改时间
截取实际长度字符串,并用空格替换
本人常用的分页代码
一句话木马连接客户端
编写网页木马详解
Asp生成HTML方法大全
利用xmlhttp和adodb.stream加缓存技术下载远程Web文件
用ASP实现远程批量文件改名
如何准确定时运行ASP文件

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 44 ::
收藏到网摘: 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

%>