Funcs: fix: use a cast in hex2val().
Funcs: refactored escapeNonPrintable().