Escaping special characters in JavaScript
<p>I need a method in JavaScript to escape all characters which are not ( a-z / A-Z / 0-9 / - / _ )</p>

<p>If the character is ø it should be replaced with oe, if it's å then replaced with aa, and more.... if characters are not on the list, they should be replaced with an underscore.</p>

<p>If there are 2 underscores in a row ( __ ) they should be replaced with a single underscore.</p>

<p>I need this done in JavaScript and/or PHP.</p>
