respect charset preference when invoking htmlentities()

as proposed in issue #123