title: Replacement for javascript escape?
body: <p>I know that the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/escape" rel="noreferrer">escape</a> function has been deprecated and that you should use encodeURI or encodeURIComponent instead. However, the encodeUri and encodeUriComponent doesn't do the same thing as escape.</p>
  <p>I want to create a mailto link in javascript with Swedish åäö. Here are a comparison between escape, encodeURIComponent and encodeURI:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var subject="åäö";
  var body="bodyåäö";
  
  console.log("mailto:?subject="+escape(subject)+"&amp;body=" + escape(body));
  console.log("mailto:?subject="+encodeURIComponent(subject)+"&amp;body=" + encodeURIComponent(body));
  console.log("mailto:?subject="+encodeURI(subject)+"&amp;body=" + encodeURI(body));  </code></pre>
  </div>
  </div>
  </p>
  <pre><code>Output:
  mailto:?subject=My%20subject%20with%20%E5%E4%F6&amp;body=My%20body%20with%20more%20characters%20and%20swedish%20%E5%E4%F6
  mailto:?subject=My%20subject%20with%20%C3%A5%C3%A4%C3%B6&amp;body=My%20body%20with%20more%20characters%20and%20swedish%20%C3%A5%C3%A4%C3%B6
  mailto:?subject=My%20subject%20with%20%C3%A5%C3%A4%C3%B6&amp;body=My%20body%20with%20more%20characters%20and%20swedish%20%C3%A5%C3%A4%C3%B6 
  </code></pre>
  <p>Only the mailto link created with &quot;escape&quot; opens a properly formatted mail in Outlook using IE or Chrome. When using encodeURI or encodeURIComponent the subject says:</p>
  <pre><code>My subject with Ã¥Ã¤Ã¶
  </code></pre>
  <p>and the body is also looking messed up.</p>
  <p>Is there some other function besides escape that I can use to get the working mailto link?</p>