Added support for encoding htmlentities