本帖最后由 DawnPine 于 2012-08-23 11:21:14 编辑

解决方案 »

  1.   

    居然没人来答。研究了二年半,终于自己搞定了
    [code]Function UTF8EncodeURI(strUTF8 As String) As String
        Dim nFor    As Long
        Dim nAsc    As Long
        Dim strWchar    As String
        Dim strURIchar  As String
        
        UTF8EncodeURI = ""
        For nFor = 1 To Len(strUTF8)
            strWchar = Mid(strUTF8, nFor, 1)
            nAsc = AscW(strWchar)
            If nAsc < 0 Then nAsc = nAsc + 65536
            If (nAsc And &HFF80) = 0 Then
                UTF8EncodeURI = UTF8EncodeURI & strWchar
            ElseIf (nAsc And &HF000) = 0 Then
                strURIchar = "%" & Hex(((nAsc \ 2 ^ 6)) Or &HC0) & Hex(nAsc And &H3F Or &H80)
                UTF8EncodeURI = UTF8EncodeURI & strURIchar
            Else
                strURIchar = "%" & Hex((nAsc \ 2 ^ 12) Or &HE0) & _
                             "%" & Hex((nAsc \ 2 ^ 6) And &H3F Or &H80) & _
                             "%" & Hex(nAsc And &H3F Or &H80)
                UTF8EncodeURI = UTF8EncodeURI & strURIchar
            End If
        Next
    End Function
    [/code]
      

  2.   


    Function UTF8EncodeURI(strUTF8 As String) As String
        Dim nFor    As Long
        Dim nAsc    As Long
        Dim strWchar    As String
        Dim strURIchar  As String
        
        UTF8EncodeURI = ""
        For nFor = 1 To Len(strUTF8)
            strWchar = Mid(strUTF8, nFor, 1)
            nAsc = AscW(strWchar)
            If nAsc < 0 Then nAsc = nAsc + 65536
            If (nAsc And &HFF80) = 0 Then
                UTF8EncodeURI = UTF8EncodeURI & strWchar
            ElseIf (nAsc And &HF000) = 0 Then
                strURIchar = "%" & Hex(((nAsc \ 2 ^ 6)) Or &HC0) & Hex(nAsc And &H3F Or &H80)
                UTF8EncodeURI = UTF8EncodeURI & strURIchar
            Else
                strURIchar = "%" & Hex((nAsc \ 2 ^ 12) Or &HE0) & _
                             "%" & Hex((nAsc \ 2 ^ 6) And &H3F Or &H80) & _
                             "%" & Hex(nAsc And &H3F Or &H80)
                UTF8EncodeURI = UTF8EncodeURI & strURIchar
            End If
        Next
    End Function