asp中自定义截取字段函数StrLeft()
2008-11-01 20:37
363 查看
<%
function StrLeft(Str,StrLen)
dim L,T,I,C
if Str="" then
StrLeft=""
exit function
end if
Str=Replace(Replace(Replace(Replace(Str," "," "),""",Chr(34)),">",">"),"<","<")
L=Len(Str)
T=0
for i=1 to L
C=Abs(AscW(Mid(Str,i,1)))
if C>255 then
T=T+2
else
T=T+1
end if
if T>=StrLen then
StrLeft=Left(Str,i) & "…"
exit for
else
StrLeft=Str
end if
next
StrLeft=Replace(Replace(Replace(replace(StrLeft," "," "),Chr(34),"""),">",">"),"<","<")
end function
例:
aa="你好我好大家好他好她好人人好"
bb=StrLeft(aa,4)
response.write(bb)
%>
显示结果:
你好我好...
function StrLeft(Str,StrLen)
dim L,T,I,C
if Str="" then
StrLeft=""
exit function
end if
Str=Replace(Replace(Replace(Replace(Str," "," "),""",Chr(34)),">",">"),"<","<")
L=Len(Str)
T=0
for i=1 to L
C=Abs(AscW(Mid(Str,i,1)))
if C>255 then
T=T+2
else
T=T+1
end if
if T>=StrLen then
StrLeft=Left(Str,i) & "…"
exit for
else
StrLeft=Str
end if
next
StrLeft=Replace(Replace(Replace(replace(StrLeft," "," "),Chr(34),"""),">",">"),"<","<")
end function
例:
aa="你好我好大家好他好她好人人好"
bb=StrLeft(aa,4)
response.write(bb)
%>
显示结果:
你好我好...
相关文章推荐
- c#中自定义字符截取函数:Left、Right 、Mid
- Delphi : 字符串截取函数LeftStr,MidStr,RightStr的用法
- delphi 字符截取函数LeftStr/MidStr/RightStr以及Copy的使用
- ASP截取两个字符串之前字符的自定义函数
- DELPHI的字符截取函数LEFTSTR, MIDSTR, RIGHTSTR的介绍以及字符串拆分
- asp.net中没有类似asp中Left()函数怎么办?
- ABAP自定义截取字符串长度函数
- ASP.NET通过自定义函数实现对字符串的大小写切换功能
- asp CutStrX字符串截取函数(过滤全部HTML标记)
- 自定义处理函数,文本处理,汉字截取
- ASP中控制字段长度的函数
- iconv_substr截取字符而不是字节数,不用额外写自定义函数哦
- php如何截取字符串并以零补齐str_pad() 函数
- ASP的一些自定义函数整理第1/2页
- log4net自定义字段写入SqlServer数据库 ASP.net
- 我常用的一些ASP自定义函数
- asp.net MVC helper 和自定义函数@functions小结
- 如何:使用自定义函数对 ASP.NET 服务器控件进行验证
- 今日收获总结(关于存储过程时间查询的一些方法以及字段截取的函数及调用示例)
- 真正根据utf8编码的规律来进行截取的字符的函数,utf8版sub_str