title: Unicode and URI encoding, decoding and escaping in JavaScript
body: <p>If you look at this <a href="http://www.w3schools.com/TAGS/ref_urlencode.asp" rel="nofollow noreferrer">table here</a>, it has a list of escape sequences for Unicode characters that don't actually work for me. </p>
  
  <p>For example for "%96", which should be a –, I get an error when trying decode:</p>
  
  <pre><code>decodeURIComponent("%96");
  URIError: URI malformed
  </code></pre>
  
  <p>If I attempt to encode "–" I actually get:</p>
  
  <pre><code>encodeURIComponent("–");
  "%E2%80%93"
  </code></pre>
  
  <p>I searched through the internet and I saw <a href="http://ecmanaut.blogspot.com/2006/07/encoding-decoding-utf8-in-javascript.html" rel="nofollow noreferrer">this page</a>, which mentions using escape and unescape with decodeURIComponent and encodeURIComponent respectively. This doesn't seem to help because %96 doesn't show up as "–" no matter what I try and this of course wouldn't work:</p>
  
  <pre><code>decodeURIComponent(escape("%96));
  "%96"
  </code></pre>
  
  <p>Not very helpful.</p>
  
  <p>How can I get "%96" to be a "–" with JavaScript (without hardcoding a map for every single possible unicode character I may run into)? </p>