A multibyte UTF-8 sequence cut short by a non-continuation byte took every remaining byte of the string, so "a\xf0Zb" became "a\ufffd". Replace only the lead byte and the continuation bytes that follow it, the same as an invalid sequence that is not cut short, so "a\xf0Zb" now becomes "a\ufffdZb". This also changes length and explode on such strings, which now count the characters that used to be dropped.