如何在vba中解码%C3%B8
如何在 VBA 中解码 %C3%B8?它是丹麦字母 ø - 它以 UTF-8 编码。我尝试在 vba 中对其进行解码,以便在 Excel 电子表格中使用以下函数:
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
How do i decode %C3%B8 in VBA? it is the danish letter ø -
It is encoded in UTF-8. I have tried to decode it in vba for use in a excel sppreadsheet with the following function:
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须使用 UrlDecode 或 HmlDecode 方法,
请参阅此处以获取更多信息
http://msdn.microsoft.com/en-us /library/system.web.httputility.urldecode.aspx
或此处
http://msdn.microsoft.com/en-us/library/7c5fyk1k.aspx
You have to use UrlDecode or HmlDecode methods
see here for more information
http://msdn.microsoft.com/en-us/library/system.web.httputility.urldecode.aspx
or here
http://msdn.microsoft.com/en-us/library/7c5fyk1k.aspx