<Extension()> _ PublicFunction HalfSubstring(ByValstrAsString, ByVal strLength AsInteger) AsString
strLength = strLength -1 Dim newStr AsString=String.Empty Dim p AsInteger
For i AsInteger=0Tostr.Length -1 Dim subStr AsString=str.Substring(i, 1) If (Regex.IsMatch(subStr, "[\u4e00-\u9fa5]")) Then
p +=2
newStr &= subStr Else
p +=1
newStr &= subStr EndIf If p > strLength Then If p > strLength +1And (Regex.IsMatch(subStr, "[\u4e00-\u9fa5]")) Then
newStr = newStr.Substring(0, newStr.Length -1) &"." ExitFor Else If (Regex.IsMatch(newStr.Substring(newStr.Length -1, 1), "[\u4e00-\u9fa5]")) Then
newStr = newStr.Substring(0, newStr.Length -1) &".." Else
newStr = newStr.Substring(0, newStr.Length -1) &"." EndIf ExitFor EndIf EndIf Next