Encode all characters that have to be escaped in HTML attributes, following https://html.spec.whatwg.org/multipage/parsing.html#escapingString.
Encode all characters that have an equivalent entity, as well as all characters that are not ASCII characters.
Encode all characters that have to be escaped in HTML text, following https://html.spec.whatwg.org/multipage/parsing.html#escapingString.
The output is UTF-8 encoded. Only characters that need escaping within XML will be escaped.
The output consists only of ASCII characters. Characters that need escaping within HTML, and characters that aren't ASCII characters will be escaped.