Try it out:
encodeURIComponent(\"\'@#$%^&\");
If you try this out you will see all the special characters are encoded except for the single
You can use:
function fixedEncodeURIComponent (str) { return encodeURIComponent(str).replace(/[!'()*]/g, escape); } fixedEncodeURIComponent("'@#$%^&");
Check reference: http://mdn.beonex.com/en/JavaScript/Reference/Global_Objects/encodeURIComponent.html