Pulled common character comparisons into one place.