Decode escaped Url without using HttpUtility.UrlDecode

前端 未结 8 1719
盖世英雄少女心
盖世英雄少女心 2020-12-05 09:52

Is there any function that converts an escaped Url string to its unescaped form? System.Web.HttpUtility.UrlDecode() can do that job but I don\'t want to add a r

8条回答
  •  抹茶落季
    2020-12-05 10:14

    @Smith
    I was having the save problem. No changes or just further jumbling.

    After testing many things I noticed a test string did decode. Ultimately I had to create a new empty string, set it's value to the encoded string then run WebUtility.HtmlDecode and Uri.UnescapeDataString on the new string. For some reason I had to run the decode and unescape in the order I mentioned. Bizarre.

    I solved it with something like this.

    Dim strEncoded as string="http%3a%2f%2fwww.google.com%2fsearch%3fhl%3den%26q%3dsomething%20%2323%26btnG%3dGoogle%2bSearch%26aq%3df%26oq%3d"
    
    Dim strDecoded as string = ""
    strDecoded = strEncoded
    strDecoded = WebUtility.HtmlDecode(strDecoded)
    strDecoded = Uri.UnescapeDataString(strDecoded)
    

提交回复
热议问题