That check is correct. Your error must be elsewhere - how are you obtaining the input characters? Please show more of the code.