怎么将字节数组和字符串进行连接,BYTE类型的函数怎么回传字符数组

解决方案 »

  1.   

    strconv( byte数组, vbunicode )
      

  2.   

    STRCONV函数转换汉字UTF-8时有问题,所有我想用自己编写一个字节数组和字符串进行连接的函数
      

  3.   

    汉字是怎么搞到byte数组里的?弱弱的问
      

  4.   

    utf8转gbOption Explicit
    Private Declare Function WideCharToMultiByte Lib "kernel32" (ByVal CodePage As Long, ByVal dwFlags As Long, ByVal lpWideCharStr As Long, ByVal cchWideChar As Long, ByRef lpMultiByteStr As Any, ByVal cchMultiByte As Long, ByVal lpDefaultChar As String, ByVal lpUsedDefaultChar As Long) As Long
    Private Declare Function MultiByteToWideChar Lib "kernel32" (ByVal CodePage As Long, ByVal dwFlags As Long, ByVal lpMultiByteStr As Long, ByVal cchMultiByte As Long, ByVal lpWideCharStr As Long, ByVal cchWideChar As Long) As Long
    Private Const CP_UTF8 = 65001
    Function Utf8ToUnicode(ByRef Utf() As Byte) As String
        Dim lRet As Long
        Dim lLength As Long
        Dim lBufferSize As Long
        lLength = UBound(Utf) - LBound(Utf) + 1
        If lLength <= 0 Then Exit Function
        lBufferSize = lLength * 2
        Utf8ToUnicode = String$(lBufferSize, Chr(0))
        lRet = MultiByteToWideChar(CP_UTF8, 0, VarPtr(Utf(0)), lLength, StrPtr(Utf8ToUnicode), lBufferSize)
        If lRet <> 0 Then
            Utf8ToUnicode = Left(Utf8ToUnicode, lRet)
        End If
    End FunctionFunction UnicodeToUtf8(ByVal UCS As String) As Byte()
        Dim lLength As Long
        Dim lBufferSize As Long
        Dim lResult As Long
        Dim abUTF8() As Byte
        lLength = Len(UCS)
        If lLength = 0 Then Exit Function
        lBufferSize = lLength * 3 + 1
        ReDim abUTF8(lBufferSize - 1)
        lResult = WideCharToMultiByte(CP_UTF8, 0, StrPtr(UCS), lLength, abUTF8(0), lBufferSize, vbNullString, 0)
        If lResult <> 0 Then
        lResult = lResult - 1
        ReDim Preserve abUTF8(lResult)
        UnicodeToUtf8 = abUTF8
        End If
    End Function
    Private Sub Command1_Click()
        Dim b() As Byte
        'byt = UnicodeToUtf8("测试")
        'Debug.Print Hex(byt(0)) & Hex(byt(1)) & Hex(byt(2))
        'Debug.Print Utf8ToUnicode(byt())
        b = StrConv("鍏叡澶村紑濮", vbFromUnicode)
        Debug.Print Utf8ToUnicode(b)
    End Sub
      

  5.   


    dim b() as byte
    b = strconv( 字符串, vbfromunicode )