This particular case fails with a string that is shorter than it should be; I think it's also theoretically possible to have an unpaired surrogate at the end.