ASP如何计算中英文混合字符串长度和截取字符串 .
2015-08-11 16:45
846 查看
计算中英文混合字符串的长度:
function getStringLen(str)
on error resume next
dim l,c,i,t
l=len(str)
t=l
for i=1 to l
c=asc(mid(str,i,1))
if c>=128 or c<0 then t=t+1
next
getStringLen=t
if err.number<>0 then err.clear
end function
截取字符串:
function getSubString(str,Length)
on error resume next
dim l,c,i,hz,en
l=len(str)
if l<length then
getSubString=str
else
hz=0
en=0
for i=1 to l
c=asc(mid(str,i,1))
if c>=128 or c<0 then
hz=hz+1
else
en=en+1
end if
if en/2+hz>=length then
exit for
end if
next
getSubString=left(str,i) & "…"
end if
if err.number<>0 then err.clear
end function
function getStringLen(str)
on error resume next
dim l,c,i,t
l=len(str)
t=l
for i=1 to l
c=asc(mid(str,i,1))
if c>=128 or c<0 then t=t+1
next
getStringLen=t
if err.number<>0 then err.clear
end function
截取字符串:
function getSubString(str,Length)
on error resume next
dim l,c,i,hz,en
l=len(str)
if l<length then
getSubString=str
else
hz=0
en=0
for i=1 to l
c=asc(mid(str,i,1))
if c>=128 or c<0 then
hz=hz+1
else
en=en+1
end if
if en/2+hz>=length then
exit for
end if
next
getSubString=left(str,i) & "…"
end if
if err.number<>0 then err.clear
end function
相关文章推荐
- 用Metasploit破解Mysql用户名和密码
- asp.net 父窗体获取子窗体的返回值,可用来对父窗体局部更新
- ASP.NET验证码(3种)
- ASP.NET WebForm
- Asp.Mvc 2.0实现用户注册实例讲解(1)
- ASP.NET MVC4之js css文件合并功能(3)
- ASP.NET MVC3模板页的使用(2)
- 检测到有潜在危险的 Request.Form 值。 说明: ASP.NET 在请求中检测到包含潜在危险的数据
- 简析ASP.NET网站的创建与发布过程
- 七天学会ASP.NET MVC(七)――创建单页应用
- 七天学会ASP.NET MVC(七)——创建单页应用
- 七天学会ASP.NET MVC(七)——创建单页应用
- ASP.NET Web Api 实践系列(二)Get/Post方式调用Web Api
- asp.net(c#)有关 Session 操作的几个误区
- aspx伪静态
- ASP.NET MVC学习小记
- ASP.NET Ajax 客户端框架未能加载、"Sys"未定义
- asp.net mvc怎么设置“起始页”
- DevExpress v15.1:ASP.NET WebForms功能增强(二)
- ASP.NET__1