Fix error handling on surrogate pairs