title: UrlDecode and ASCII characters in C#
body: <p>I'm working on a project that is integrated with a payment provider (epdq). They pass variables of the successful payment back in a querystring to our website. Part of the querystring that is passed back includes the customers name. We have noticed that if someone enters a special character, such as '£' the querystring parameters is returned like so: CN=Mr+%A3Test+Test</p>
  
  <p>This is quite strange because I thought the UrlEncoded value for the £ symbol was %C2%A3. </p>
  
  <p>Regardless, this is causing issues because we have to decode the values passed back in the querystring and get their true value, in this instance the £ symbol.</p>
  
  <p>I've tried two different ways of doing it:</p>
  
  <pre><code>            foreach (var key in querystring.Keys)
          {
              var enc = System.Text.Encoding.GetEncoding("iso-8859-1");
              Logger.Debug(HttpUtility.ParseQueryString(querystring.ToString(), enc)[key.ToString()]);
              Logger.Debug(HttpUtility.UrlDecode(querystring.Get(key.ToString()), enc));
          }
  </code></pre>
  
  <p>I've tried it with both iso-8859-1 and utf-8. Both however convert the string to 'Mr �Test Test', obviously a character it hasn't been able to convert back properly.</p>
  
  <p>Other than using a regular expression and searching the string for a whole host of possible characters that the customer could input, and then convert them from their ASCII equivalent (I note in ASCII %A3 is the £ symbol) I'm not sure where else to go with this.</p>
  
  <p>Can anyone provide any pointers?</p>
  
  <p>Thanks for your time in advance</p>
  
  <p>dotdev</p>