Decode URL
Although we have heard of an @-function that will decode a URL, but it is undocumentend at this time. In the mean time, here is a generic LotusScript function that will decode any URL.Update: We have been made aware that the older version of this function did not handle Unicode characters. They are encoded with a "%u" prefix and include 4 hex characters after the "%u". The version below supports Unicode characters.
URL's are encoded by replacing spaces with plus signs and replacing symbols with "%" followed by their 2 digit (hex) ASCII value. The character "%" is encoded to "%25", so all "%" characters are encoded, and the "+" character is encoded to "%2B", so all "+" characters are replaced spaces. Note that "%" can be used or "%x" to get the same result (%2B = %x2B = the + character). Instead of listing out all the possible characters in a big "case" statement, this function acts generically:
Function URLDecode(inpString As String) As String
Dim temp As String
Dim hexValue As String
Dim ch As String
Dim pos As Integer
Dim newPos As Integer
' First, replace any plus signs with spaces
temp = inpString
While Instr(temp, "+") <> 0
temp = Left(temp, Instr(temp, "+")-1) & " " & Mid(temp, Instr(temp, "+")+1)
Wend
' Next, replace any "%x" encodings with the character
pos = 1
While Instr(pos, temp, "%x") <> 0
hexValue = Mid(temp, Instr(pos, temp, "%x")+2, 2)
ch = Chr$(Val("&H" & hexValue))
newPos = Instr(pos, temp, "%x")+2
temp = Left(temp, Instr(pos, temp, "%x")-1) & ch & Mid(temp, Instr(pos, temp, "%x")+4)
pos = newPos
Wend
' Next, replace any "%u" encodings with the Unicode character
pos = 1
While Instr(pos, temp, "%u") <> 0
hexValue = Mid(temp, Instr(pos, temp, "%u")+2, 4) ' Unicode encodings are 4 hex characters
ch = Uchr$(Val("&H" & hexValue))
newPos = Instr(pos, temp, "%u")+2 ' Skip over so we don't find "%" if that's what it was decoded to
temp = Left(temp, Instr(pos, temp, "%u")-1) & ch & Mid(temp, Instr(pos, temp, "%u")+6)
pos = newPos
Wend
' Next, replace any "%" encodings with the character
pos = 1
While Instr(pos, temp, "%") <> 0
hexValue = Mid(temp, Instr(pos, temp, "%")+1, 2)
ch = Chr$(Val("&H" & hexValue))
newPos = Instr(pos, temp, "%")+1
temp = Left(temp, Instr(pos, temp, "%")-1) & ch & Mid(temp, Instr(pos, temp, "%")+3)
pos = newPos
Wend
URLDecode = temp
End Function