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