如何在VBA中解码%C3%B8?这是丹麦字母ø - 它以UTF-8编码。我试图在vba中解码它,以便在具有以下功能的excel sppreadsheet中使用:
Function DecodeUTF8(s)
Dim i
Dim c
Dim n
i = 1
Do While i <= Len(s)
c = Asc(Mid(s, i, 1))
If c And &H80 Then
n = 1
Do While i + n < Len(s)
If (Asc(Mid(s, i + n, 1)) And &HC0) <> &H80 Then
Exit Do
End If
n = n + 1
Loop
If n = 2 And ((c And &HE0) = &HC0) Then
c = Asc(Mid(s, i + 1, 1)) + &H40 * (c And &H1)
Else
c = 191
End If
s = Left(s, i - 1) + Chr(c) + Mid(s, i + n)
End If
i = i + 1
Loop
DecodeUTF8 = s
End Function
答案 0 :(得分:0)
您必须使用UrlDecode或HmlDecode方法
请点击此处了解更多信息 http://msdn.microsoft.com/en-us/library/system.web.httputility.urldecode.aspx