Fix htmlentities encoding issue for PHP < 5.4