Unescaping characters in an HTTP query string


using System;
using System.Text.RegularExpressions;
class Program
{
    static void Main(string[] args)
    {

     string sample = "Space%20Space"; 

     string result = Regex.Replace ( 
          sample, 
          @"%[0-9a-f][0-9a-f]", 
          m => ((char) Convert.ToByte (m.Value.Substring (1), 16)).ToString(), 
          RegexOptions.IgnoreCase 
      ); 

     Console.WriteLine (result);         
   }
}

The output:


Space Space
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.