开发者

How to decode %C3%B8 in vba

开发者 https://www.devze.com 2023-04-11 02:25 出处:网络
How do i decode %C3%B8 in VBA? it is the danish letter ø - I开发者_运维问答t is encoded in UTF-8. I have tried to decode it in vba for use in a excel sppreadsheet with the following function:

How do i decode %C3%B8 in VBA? it is the danish letter ø - I开发者_运维问答t 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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号