To quote from ISO 8879:1986 Clause 9.5, lines 8-13, 14, 19-22:
A replacement character is considered to be in the same entity as
its reference.
A replacement character is treated as though it were entered
directly except that the replacement for a numeric character
reference is always treated as data in the context in which
the replacement occurs.
NOTES
2 When a document is translated to a different document character
set, the character number of each numeric character reference must
be changed to the corresponding character number of the new set.