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

ASP
asp调用存储过程
利用批处理文件和 vbs 脚本实现网站视频自动录制
ASP、vbscript编码模板
FileSystem对象常用的文件操作函数有哪些?
asp显示日历效果
sql语句的一些集合
ASP语法注释
函数名称 函数功能
万能数据库连接程序
记录集内随机取记录的代码
分页代码
如何在数据库中用好Transaction?
用Command对象和RecordSet对象向数据库增加记录哪一个更好
为什么在存储过程中用OLEDB方式不能返回记录集
如何查询日期类型的数据?
ASP如何获取真实IP地址
两种小偷程序的比较
使用xmlHttp结合ASP实现网页的异步调用
用ASP开"多线程"
整理了一个editplus的剪辑文件(ASP方面的内容)

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


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

%>