Javascript encodeURIComponent doesn’t encode single quotes

I’m not sure why you would want them to be encoded. If you only want to escape single quotes, you could use .replace(/'/g, "%27"). However, good references are:

  • When are you supposed to use escape instead of encodeURI / encodeURIComponent?
  • Comparing escape(), encodeURI(), and encodeURIComponent() at xkr.us
  • Javascript Madness: Query String Parsing #Javascript Encode/Decode Functions

Leave a Comment