Fix compiler warnings correctly.

"static_cast<unsigned char>(c) == c" is architecture dependent. New fix does exactly what the original code did.