Invariant checking added to the UTF encoder