code: def legacy_html_escape(s):
      
      s = s.replace("&", "&amp;")
      s = s.replace(">", "&gt;")
      s = s.replace("<", "&lt;")
      s = s.replace('"', "&#34;")
      s = s.replace("'", "&#39;")
      return s
docs: legacy HTML escape for non-unicode mode.