Handed invalid characters in a more general way