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

ASP
ASP编程入门进阶(廿一):DAO SQL之建立数据库表
ASP应用之模板采用
ASP上传图片功能的又一实现(OLE对象)
asp中FSO复制文件代码
asp复制文件夹代码
实例演练ASP+XML编程比较全的了
利用ASP从远程服务器上接收XML数据的方法
PJ-Blog教程┊增强博客用户体验~让发表内容的同时拷贝到剪贴板以防丢失
TSYS一个新闻多种特性时如何进行前台更新?
TSYS资源特性的效率提高方法
重置TSYS系统中的所有"生成的文件"成"未生成文件"
TSYS中生成静态页时溢出: ''CInt''
asp实现防止站外提交内容的两个方法
ASP中生成文本文件的两种方式
ASP是否可以定时触发事件
ASP解压缩(在线解压缩类)
使用ASP删除指定IIS站点
使用ASP控制指定站点解析脚本语言函数
HTML标签及ASP函数速查表
如何使用Administrators组用户运行ASP程序

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


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

%>