Consumes the WTF-8 string and converts it lossily to UTF-8. This does not copy the data (but may overwrite parts of it in place). Surrogates are replaced with `"\u{FFFD}"` (the replacement character “�”)
(mut self)
| 546 | /// |
| 547 | /// Surrogates are replaced with `"\u{FFFD}"` (the replacement character “�”) |
| 548 | pub fn into_string_lossy(mut self) -> String { |
| 549 | let mut pos = 0; |
| 550 | while let Some((surrogate_pos, _)) = self.next_surrogate(pos) { |
| 551 | pos = surrogate_pos + 3; |
| 552 | // Surrogates and the replacement character are all 3 bytes, so |
| 553 | // they can substituted in-place. |
| 554 | self.bytes[surrogate_pos..pos].copy_from_slice(UTF8_REPLACEMENT_CHARACTER.as_bytes()); |
| 555 | } |
| 556 | unsafe { String::from_utf8_unchecked(self.bytes) } |
| 557 | } |
| 558 | |
| 559 | /// Converts this `Wtf8Buf` into a boxed `Wtf8`. |
| 560 | #[inline] |
nothing calls this directly
no test coverage detected