asp 中西文混合式字符截取程序

2015-08-12 16:03:09来源:作者:人点击

中西文混合式字符截取程序
function CutStr(byVal val,byVal length,byVal endStr)
  Dim l,t,c,i
  If val = "" Or IsNull(val) Then
   CutStr = ""
   Exit Function
  End If
  If length = "" Or Int(length) <= 0 Or IsNumeric(length) = False Then
   CutStr = val
   Exit Function
  End If
  val = LoseHTML(val)
  l = Len(val)
  length = Int(length)
  t = 0
  For i = 1 To l
   c = Ascw(Mid(val,i,1))
   If c < 0 Or c > 255 Then t = t + 2 Else t = t + 1
   IF t >= length Then
    CutStr = Left(val,i) & endStr
    Exit For
   Else
    CutStr = val
   End If
  Next
 End Function

最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台