An HTML character reference is source notation that a conforming parser can resolve to one or more characters. EntityCodec treats the input as bounded text and never claims to parse a complete document.

Three visible forms

A reference may use a name such as &, a decimal code point such as &, or a hexadecimal code point such as &. All three can represent an ampersand, but their readability and portability differ.

Encoding can have layers

The text © decodes once to © and only a second pass produces ©. EntityCodec deliberately performs one decode pass so the boundary remains observable.

Verify the exact destination

Character-reference encoding changes text representation, not the trust level of the data. Keep the output as text until the receiving system applies the correct context-specific escaping or sanitization. Compare the complete result after pasting it into that system. For a repeatable check, keep one literal fixture beside its expected encoded form, run the same selected profile twice, and compare every ampersand, semicolon, code point, space, and line break. Then test the receiving text binding with harmless representative characters. If the destination rewrites, normalizes, repeatedly decodes, or renders the value, document that later behavior separately because it is outside EntityCodec.