Use std::iscntrl instead of !isprint to detect non printable characters.