完美字符串截取
来源:互联网 发布:js身份证号码验证规则 编辑:程序博客网 时间:2024/05/08 03:18
<%
Function CountLength(Str)
Dim output,ThisChar,i
output = 0
For i = 1 To Len(Str)
ThisChar = Mid(Str,i,1)
If Asc(ThisChar) < 0 Then
output = output + 2
Else
output = output + 1
End If
Next
CountLength = output
End Function
Function MaxLengthStr(ByVal Str, ByVal MaxLength)
Dim Output,i
If IsNull(Str) Then Str = ""
Output = ""
If LenB(Str) <= MaxLength Then
Output = Str
Else
For i = 1 To Len(Str)
Output = Output & Mid(Str,i,1)
If CountLength(Output)+3 = MaxLength Then
Output = Output & "..."
Exit For
ElseIf CountLength(Output)+3 > MaxLength Then
Output = Left(Output,Len(Output)-1) & "..."
Exit For
End If
Next
End If
MaxLengthStr = Output
End Function
Response.Write MaxLengthStr("Osdne Wor21421阿瑟大ld One Dream,北京", 40)
response.write "<br>"
Response.Write MaxLengthStr("北京2008,Onsf234eWorld One Dream,北京2008", 41)
Function Strlength(Str)
Temp_Str=Len(Str)
For I=1 To Temp_Str
Test_Str=(Mid(Str,I,1))
If Asc(Test_Str)>0 Then
Strlength=Strlength+1
Else
Strlength=Strlength+2
End If
Next
End Function
Function Strleft(Str,L)
Temp_Str=Len(Str)
For I=1 To Temp_Str
Test_Str=(Mid(Str,I,1))
Strleft=Strleft&Test_Str
If Asc(Test_Str)>0 Then
lens=lens+1
Else
lens=lens+2
End If
If lens>=L Then Exit For
Next
End Function
Response.Write Strleft("北008",3)
%>
Function CountLength(Str)
Dim output,ThisChar,i
output = 0
For i = 1 To Len(Str)
ThisChar = Mid(Str,i,1)
If Asc(ThisChar) < 0 Then
output = output + 2
Else
output = output + 1
End If
Next
CountLength = output
End Function
Function MaxLengthStr(ByVal Str, ByVal MaxLength)
Dim Output,i
If IsNull(Str) Then Str = ""
Output = ""
If LenB(Str) <= MaxLength Then
Output = Str
Else
For i = 1 To Len(Str)
Output = Output & Mid(Str,i,1)
If CountLength(Output)+3 = MaxLength Then
Output = Output & "..."
Exit For
ElseIf CountLength(Output)+3 > MaxLength Then
Output = Left(Output,Len(Output)-1) & "..."
Exit For
End If
Next
End If
MaxLengthStr = Output
End Function
Response.Write MaxLengthStr("Osdne Wor21421阿瑟大ld One Dream,北京", 40)
response.write "<br>"
Response.Write MaxLengthStr("北京2008,Onsf234eWorld One Dream,北京2008", 41)
Function Strlength(Str)
Temp_Str=Len(Str)
For I=1 To Temp_Str
Test_Str=(Mid(Str,I,1))
If Asc(Test_Str)>0 Then
Strlength=Strlength+1
Else
Strlength=Strlength+2
End If
Next
End Function
Function Strleft(Str,L)
Temp_Str=Len(Str)
For I=1 To Temp_Str
Test_Str=(Mid(Str,I,1))
Strleft=Strleft&Test_Str
If Asc(Test_Str)>0 Then
lens=lens+1
Else
lens=lens+2
End If
If lens>=L Then Exit For
Next
End Function
Response.Write Strleft("北008",3)
%>
- 完美字符串截取
- PHP截取字符串完美版,不用担心中文截取乱码
- smarty模板截取字符串乱码问题完美解决```````
- 完美截取Office2003图标
- css截取截取字符串
- 字符串截取
- 字符串截取
- 字符串截取
- 截取字符串
- 截取字符串
- 截取字符串
- 字符串截取
- 字符串截取
- 截取字符串
- 截取字符串
- 截取字符串
- 截取字符串
- 字符串截取
- 基于.NET平台的MapX开发
- Java文件操作大全
- 基于MapXtreme的WebGPS系统的设计与实现
- sql server2000 函数的类型和实例
- c#之半角转全角
- 完美字符串截取
- Indexof与BinarySearch的比较
- C++中的#符号
- 35岁前成功的12条黄金法则
- sahu1990‘s blog终于开张了
- 魔王※公主
- 个人单机数据库、联网数据库
- C#中using的使用
- 23种设计模式幽默见解