Escape replaces characters with special meaning in XML to prevent
prompt injection when embedding user content in XML-delimited templates.
Invalid UTF-8 sequences are replaced with the Unicode replacement character
(U+FFFD) before escaping so that xml.EscapeText never fails.