title: Sanitizing string to make it URL and filename safe?
body: <p>I need javascript to create the exact same url-safe filename as I have created in PHP.</p>
  
  <p>This is my code in PHP:</p>
  
  <pre><code>&lt;?php
  $clean_name = strtr($string, 'ŠŽšžŸÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖØÙÚÛÜÝàáâãäåçèéêëìíîïñòóôõöøùúûüýÿ', 'SZszYAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy');
  $clean_name = strtr($clean_name, array('Þ' =&gt; 'TH', 'þ' =&gt; 'th', 'Ð' =&gt; 'DH', 'ð' =&gt; 'dh', 'ß' =&gt; 'ss', 'Œ' =&gt; 'OE', 'œ' =&gt; 'oe', 'Æ' =&gt; 'AE', 'æ' =&gt; 'ae', 'µ' =&gt; 'u'));
  
  $clean_name = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $clean_name);
  $clean_name = strtolower($clean_name);
  
  ?&gt;
  </code></pre>
  
  <p>How would I replicate that in Javascript?</p>