fix segfault due to using isdigit with non unsigned char value. Closes T1625

Also rename _termpty_handle_seq() to termpty_handle_seq() since it's not static.