Extract ascii range check to a function