0

Say I have the following Javascript:

var userString = "..."; // e.g. "cats < dogs"

How do I get userString with all html characters escaped?

E.g. I want cats &lt; dogs.

Also, how do I do the same thing with escaping all URL characters?

E.g. I want cats%20%3C%20dogs

I realize I could use a function such as this, but it seems to be non-exhaustive. E.g. it's missing &quot;.

Since Javascript does not seem to have a built-in method, I'm hoping that Google Apps Script has a built-in solution.

Lee Taylor
  • 7,155
  • 14
  • 29
  • 44
Senseful
  • 79,995
  • 61
  • 289
  • 423

1 Answers1

1

From what I can tell, you need to use a function such as this for HTML encoding, and encodeURI() for URLs.

Senseful
  • 79,995
  • 61
  • 289
  • 423