New method, for handling replacing invalid chars w/ htmlentities. Fixes #1446