Handle encoding in HTMLEntities