as this is not cheap operation maybe have `if reason.valid_encoding?` around can help.