diff --git a/wstr/src/utils.rs b/wstr/src/utils.rs index 80eae3bdb..ac9d9af1d 100644 --- a/wstr/src/utils.rs +++ b/wstr/src/utils.rs @@ -155,11 +155,13 @@ impl<'a> Iterator for AvmUtf8Decoder<'a> { ch <<= 6; ch |= (*b & (u8::MAX >> 2)) as u32; } - if ch <= 128 { - self.index += 1; - ch = first as u32; - } else if !fail { - self.index += mb_count as usize + 1; + if !fail { + if ch <= 128 { + self.index += 1; + ch = first as u32; + } else { + self.index += mb_count as usize + 1; + } } } None => {