How to decode "\u0026" in a URL?

Xaqron picture Xaqron · Aug 9, 2011 · Viewed 24.2k times · Source

I want decode URL A to B:

A) http:\/\/example.com\/xyz?params=id%2Cexpire\u0026abc=123

B) http://example.com/xyz?params=id,expire&abc=123

This is a sample URL and I look for a general solution not A.Replace("\/", "/")...

Currently I use HttpUtility.UrlDecode(A, Encoding.UTF8) and other Encodings but cannot generate URL B !

Answer

Bikrone picture Bikrone · Jun 23, 2013

You only need this function

System.Text.RegularExpressions.Regex.Unescape(str);