Consumes the WTF-8 string and tries to convert it to UTF-8. This does not copy the data. If the contents are not well-formed UTF-8 (that is, if the string contains surrogates), the original WTF-8 string is returned instead.
(self)
| 533 | /// (that is, if the string contains surrogates), |
| 534 | /// the original WTF-8 string is returned instead. |
| 535 | pub fn into_string(self) -> Result<String, Wtf8Buf> { |
| 536 | if self.is_utf8() { |
| 537 | Ok(unsafe { String::from_utf8_unchecked(self.bytes) }) |
| 538 | } else { |
| 539 | Err(self) |
| 540 | } |
| 541 | } |
| 542 | |
| 543 | /// Consumes the WTF-8 string and converts it lossily to UTF-8. |
| 544 | /// |