Skip to content

Instantly share code, notes, and snippets.

@moorer2k
Last active June 3, 2018 04:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moorer2k/ae58fe0d3c7de76887f90a742e7bdfbd to your computer and use it in GitHub Desktop.
Save moorer2k/ae58fe0d3c7de76887f90a742e7bdfbd to your computer and use it in GitHub Desktop.
decodeURI Javascript equivlent for VB.NET. When DecodeURL / Unescape does not work for you.
Public Function DecodeUri(ByVal inputText As String)
Dim rx As New System.Text.RegularExpressions.Regex("(\\x.{2})")
For Each m As System.Text.RegularExpressions.Match In rx.Matches(inputText)
inputText = inputText.Replace(m.Groups(1).Value, Chr(m.Groups(1).Value.Replace("\x", "&H")))
Next
inputText = WebUtility.UrlDecode(inputText)
If inputText.Contains("%") Then 'just make sure it's actually fully decoded. Sometimes it skips a necessary step for all parameters to be decoded.
inputText = WebUtility.UrlDecode(inputText)
End If
Return inputText
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment