locked
can`t browse URL RRS feed

  • Question

  • User-1133212568 posted

    i get the below url but i can`t browse it , how can i convert it it a normal URLfor example :

    \u003 means =

    how can i convert it in vb.net

    https://google.com/u003dk9hr43hd21tvjg943c0\u0026EmpId\u003d574066725965820\u0026DOjjgID\u003dC70BAA454D83511C5CADAEC071226C925FB\u0026o\u003dpt\u0026action\u003dretry

    Thursday, September 1, 2016 6:40 PM

Answers

  • User283571144 posted

    Hi wkhalifa,

    i need a function to change all \u003d to its original character which is =

    and \ud0026 to its original character which is &

    I suggest you could try follow codes:

     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Dim url As String = "https://google.com/u003dk9hr43hd21tvjg943c0\u0026EmpId\u003d574066725965820\u0026DOjjgID\u003dC70BAA454D83511C5CADAEC071226C925FB\u0026o\u003dpt\u0026action\u003dretry"
            Dim DecodedString As String = System.Text.RegularExpressions.Regex.Unescape(url)
            HyperLink1.NavigateUrl = DecodedString
        End Sub

    Result:

    Best Regards,

    Brando

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 6, 2016 10:18 AM
  • User-1133212568 posted

    thank you very much and i get another solution also

    Function DecodeURL(ByVal url As String) As String
            Try
                Dim stringSeparators() As String = {"\u"}
                Dim strParts() As String = url.Split(stringSeparators, StringSplitOptions.None)
                For i As Int16 = 0 To strParts.Length - 1
                    Dim StartIndex As Integer = url.IndexOf("\u")
                    If StartIndex > 1 Then
                        Dim chrToChange As String = url.Substring(StartIndex, 6)
                        Dim FromHex As Int16 = Int16.Parse(chrToChange.Substring(2), System.Globalization.NumberStyles.HexNumber)
                        Dim NewChar As String = ChrW(FromHex)
                        url = url.Replace(chrToChange, NewChar)
                    End If
                Next
                Return url
            Catch ex As Exception
                Return ""
            End Try
        End Function

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 6, 2016 2:02 PM

All replies

  • User283571144 posted

    Hi wkhalifa,

    how can i convert it in vb.net

    According to your description, I suggest you could use HttpUtility.UrlDecode method or Uri.UnescapeDataString method to convert the URL.

    More details, you could refer to follow codes and link:

    Dim url As String = "https://google.com/u003dk9hr43hd21tvjg943c0&EmpId=574066725965820&DOjjgID=C70BAA454D83511C5CADAEC071226C925FB&o=pt&action=retry"
    url = HttpUtility.UrlDecode(url)
    url = Uri.UnescapeDataString(url)
    HyperLink1.NavigateUrl = url

    Result:

    Link:

    https://msdn.microsoft.com/en-us/library/adwtk1fy(v=vs.110).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1

    https://msdn.microsoft.com/en-us/library/system.uri.unescapedatastring(v=vs.110).aspx

    Best Regards,

    Brando

    Friday, September 2, 2016 2:50 AM
  • User-1133212568 posted

    it output the same url
    all i need is when i have this url

    https://google.com/u003dk9hr43hd21tvjg943c0\u0026EmpId\u003d574066725965820\u0026DOjjgID\u003dC70BAA454D83511C5CADAEC071226C925FB\u0026o\u003dpt\u0026action\u003dretry

    i need a function to change all \u003d to its original character which is =

    and \ud0026 to its original character which is &

    Friday, September 2, 2016 1:02 PM
  • User283571144 posted

    Hi wkhalifa,

    i need a function to change all \u003d to its original character which is =

    and \ud0026 to its original character which is &

    I suggest you could try follow codes:

     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Dim url As String = "https://google.com/u003dk9hr43hd21tvjg943c0\u0026EmpId\u003d574066725965820\u0026DOjjgID\u003dC70BAA454D83511C5CADAEC071226C925FB\u0026o\u003dpt\u0026action\u003dretry"
            Dim DecodedString As String = System.Text.RegularExpressions.Regex.Unescape(url)
            HyperLink1.NavigateUrl = DecodedString
        End Sub

    Result:

    Best Regards,

    Brando

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 6, 2016 10:18 AM
  • User-1133212568 posted

    thank you very much and i get another solution also

    Function DecodeURL(ByVal url As String) As String
            Try
                Dim stringSeparators() As String = {"\u"}
                Dim strParts() As String = url.Split(stringSeparators, StringSplitOptions.None)
                For i As Int16 = 0 To strParts.Length - 1
                    Dim StartIndex As Integer = url.IndexOf("\u")
                    If StartIndex > 1 Then
                        Dim chrToChange As String = url.Substring(StartIndex, 6)
                        Dim FromHex As Int16 = Int16.Parse(chrToChange.Substring(2), System.Globalization.NumberStyles.HexNumber)
                        Dim NewChar As String = ChrW(FromHex)
                        url = url.Replace(chrToChange, NewChar)
                    End If
                Next
                Return url
            Catch ex As Exception
                Return ""
            End Try
        End Function

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 6, 2016 2:02 PM