vbscript| Function | The left () function of the Chinese character is VBScript, and VBScript considers 1 characters as 1 characters, so the left () does not get the correct character length.
I wrote the following 3 functions to replace Len (), left () and right () in the hope of solving your problem.
'--------------------------------------------------------
' Name:lenx
' Argument:ustr
' Return:
' Description: Returns the length of the string, 1 Chinese characters length is 2
'--------------------------------------------------------
Function Lenx (ByVal uStr)
Dim thelen,x,testustr
TheLen = 0
For x = 1 to Len (USTR)
Testustr = Mid (ustr,x,1)
If ASC (TESTUSTR) < 0 Then
TheLen = TheLen + 2
Else
TheLen = TheLen + 1
End If
Next
Lenx = TheLen
End Function
'--------------------------------------------------------
' Name:leftx
' Argument:ustr strings to be processed
' The length of the Ulen to intercept
' Return:
' Description: Returns a string of the specified length, 1 Chinese characters length 2
'--------------------------------------------------------
Function Leftx (ByVal ustr,byval Ulen)
Dim i,j,uteststr,thestr
LEFTX = ""
j = 0
For i = 1 to Len (USTR)
uteststr= Mid (ustr,i,1)
Thestr = thestr & Uteststr
If ASC (UTESTSTR) < 0 Then
j = j + 2
Else
j = j + 1
End If
If J >= Ulen then exit for
Next
LEFTX = Thestr
End Function
'--------------------------------------------------------
' Name:rightx
' Argument:ustr strings to be processed
' The length of the Ulen to intercept
' Return:
' Description: Returns a string of the specified length, 1 Chinese characters length 2
'--------------------------------------------------------
Function Rightx (ByVal ustr,byval Ulen)
Dim i,j,uteststr
RIGHTX = ""
j = 0
For i = Len (uStr) to 1 step-1
Uteststr = Mid (ustr,i,1)
RIGHTX = rightx & Uteststr
If ASC (UTESTSTR) < 0 Then
j = j + 2
Else
j = j + 1
End If
If J >= Ulen then exit for
Next
End Function