more character entity handling and  escaping