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 btoa() and atob(), this encodes and decodes the given string including single quote.
btoa()
atob()