Distinguish invalid and incomplete UTF-8 input, and set errno accordingly.