Cast incoming characters to unsigned char to avoid accidental sign