ASP UTF-8编码下字符串截取和获取长度函数
ASP UTF-8编码下字符串截取和获取长度函数
发布时间:2016-12-29 来源:查字典编辑
摘要:复制代码代码如下:'************************************'截取文字长度函数,支持UTF-8'输入参数:'...

复制代码 代码如下:

'************************************

'截取文字长度函数,支持UTF-8

'输入参数:

' 1、文字内容

' 2、文字最大长度

'************************************

Public Function Cut_Title(Title,TLen)

Dim k,i,d,c

Dim iStr

Dim ForTotal

If CDbl(TLen) > 0 Then

k=0

d=StrLen(Title)

iStr=""

ForTotal = Len(Title)

For i=1 To ForTotal

c=Abs(AscW(Mid(Title,i,1)))

If c>255 Then

k=k+2

Else

k=k+1

End If

iStr=iStr&Mid(Title,i,1)

If CLng(k)>CLng(TLen) Then

iStr=iStr".."

Exit For

End If

Next

Cut_Title=iStr

Else

Cut_Title=""

End If

End Function

'*******************************

'检测文字长度函数,支持UTF-8

'输入参数:

' 1、文字内容

'*******************************

Public Function StrLen(strText)

Dim k,i,c

Dim ForTotal

k=0

ForTotal = Len(strText)

For i=1 To ForTotal

c=Abs(AscW(Mid(strText,i,1)))

If c>255 Then

k=k+2

Else

k=k+1

End If

Next

StrLen=k

End Function

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新ASP教程学习
热门ASP教程学习
编程开发子分类