Last active
June 3, 2018 04:17
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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