Function AnsiLeftB(ByVal strArg As String, ByVal arg1 As Integer) As String
        Dim unicodeEncoding As Encoding = Encoding.GetEncoding("Shift_JIS")
        Dim unicodeBytes() As Byte = unicodeEncoding.GetBytes(strArg)

        Dim tempLen As Integer = 0
        For i As Integer = 0 To strArg.Length
            Dim j As Integer = unicodeEncoding.GetByteCount(strArg(i))
            If tempLen + j <= arg1 Then
                tempLen = tempLen + j
            Else
                Exit For
            End If
        Next
        Dim tempBytes(tempLen) As Byte
        Array.Copy(unicodeBytes, tempBytes, tempLen)
        AnsiLeftB = unicodeEncoding.GetString(tempBytes)
    End Function
View Code

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-04
  • 2022-12-23
  • 2022-12-23
  • 2021-07-09
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-22
  • 2021-11-01
  • 2022-03-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案