function escapeHtml(unsafe) {
  return unsafe
      .replace(/<br>/g, "\r")
      .replace(/&/g, "&amp;")
      .replace(/</g, "&lt;")
      .replace(/>/g, "&gt;")
      .replace(/"/g, "&quot;")
      .replace(/'/g, "&#039;");
 }

 function encodeHtml(unsafe) {
  return unsafe
      .replace(/\n/g, "<br>")
      .replace(/&amp;/g, "&")
      .replace(/&lt;/g, "<")
      .replace(/&gt;/g, ">")
      .replace(/&quot;/g, "\"")
      .replace(/&#039;/g, "'");
 }
