Hej Här är en hyffsad variant för VB6 som jag har knackat ihop.Avkodning av URL
Jag hittade denna koden bland tips & tricks....
och den fungerar perfekt...men det jag vill är att den ska göra det tvärtom
så att URL koden man får in blir i rätt text så att säga...
jag vill att " Kalle+%E4r+5+%E5r" blir "Kalle är 5 år"
<code>
Public Function URLEncode(Value As String) As String
Dim Index As Long
Dim lAsc As Long
Dim sChar As String
Dim sTemp As String
Dim sResult As String
For Index = 1 To Len(Value)
sChar = Mid(Value, Index, 1)
Select Case sChar
Case " "
sResult = sResult + "+"
Case "a" To "z", "A" To "Z", "0" To "9"
sResult = sResult + sChar
Case Else
lAsc = Asc(sChar)
Select Case lAsc
Case 0 To 255 'non DBCs character
sResult = sResult + "%" + Right("00" + Hex(Asc(sChar)), 2)
Case Else 'DBCs character
sTemp = Right("0000" + Hex(lAsc), 4)
sResult = sResult + "%" + Left(sTemp, 2) + "%" + Right(sTemp, 2)
End Select
End Select
Next
URLEncode = sResult
End Function
</code>
Hoppas att någon kan hjälpa mig med detta problemSv: Avkodning av URL
<code>
Private Sub Form_Load()
Dim MyString As String
MyString = "%22Jomenvisst+s%F6rru%2C+det+h%E4r+funka+ju+r%E4tt+s%E5+bra+he+he+%3A-)%22"
MyString = UrlDecode(MyString)
MsgBox "[" & MyString & "]"
End Sub
Private Function UrlDecode(ByVal str As String) As String
Dim bufString As String
Dim n As Long
Dim c As String
Dim skipped As Long
Dim hexChr As String
bufString = Space$(Len(str))
Do
n = n + 1
c = Mid$(str, n, 1)
Select Case c
Case "a" To "z", "A" To "Z", "0" To "9", "-", "_", ".", "!", "~", "*", "'", "(", ")"
Mid$(bufString, n + skipped, 1) = c
Case "+"
Mid$(bufString, n + skipped, 1) = " "
Case "%"
hexChr = Mid$(str, n + 1, 2)
Mid$(bufString, n + skipped, 1) = Chr(CLng("&H" & hexChr))
n = n + 2
skipped = skipped - 2
End Select
Loop Until Len(c) = 0
UrlDecode = Left$(bufString, n + skipped - 1)
End Function
</code>