专注于互联网--专注于架构

最新标签
网站地图
文章索引
Rss订阅

首页 »Asp教程 » 截取字符串函数:字符长度测试和截取函数(可以测试1个汉字占两个字符长度) »正文

截取字符串函数:字符长度测试和截取函数(可以测试1个汉字占两个字符长度)

来源: 发布时间:星期四, 2009年2月12日 浏览:708次 评论:0


\'*************测串长度**************

Function CheckStringLength(txt)
txt=trim(txt)
x = len(txt)
y = 0
for ii = 1 to x
asc(mid(txt,ii,1)) < 0 or asc(mid(txt,ii,1)) >255 then \'如果是汉字
y = y + 2

y = y + 1
end
next
CheckStringLength = y

End Function\'************* 截取串 **************

function InterceptString(txt,length)
txt=trim(txt)
x = len(txt)
y = 0
x >= 1 then
for ii = 1 to x
asc(mid(txt,ii,1)) < 0 or asc(mid(txt,ii,1)) >255 then \'如果是汉字
y = y + 2

y = y + 1
end
y >= length then
txt = left(trim(txt),ii) \'串限长
exit for
end
next
InterceptString = txt

InterceptString = \"\"
end

End Function
0

相关文章

读者评论

发表评论

  • 昵称:
  • 内容: