guard against utf-8 invalid byte sequence