-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
If you have a Vec<u8>
of utf8 data there's three ways to get a String
:
from_utf8(vec: Vec<u8>) -> Result<String, FromUtf8Error>
from_utf8_lossy(v: &'a [u8]) -> Cow<'a, str>
unsafe fn from_utf8_unchecked(bytes: Vec<u8>) -> String
There doesn't appear to be any way to hand over the existing Vec<u8>
and have any necessary character changes into �
be done in place. The std::string::FromUtf8Error
type doesn't, for example, have a way to just do a lossy in-place conversion.
FeldrinH, yhx-12243 and j178
Metadata
Metadata
Assignees
Labels
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.