Functions to encode/decode text for use in HTML and JavaScript.