Fix a check for invalid encoding.