improve error handling when input cannot be encoded by texenc