Can I deliberately construct a non-UTF-8 OsString?

To test some code that deals with validation, I'd like to construct an OsString with non-UTF-8 data, something like OsString::from(b"\xff") - but that doesn't work. Does anyone know if this is possible?

It depends if you're on windows or unix-likes including linux. On windows it's OsStringExt::from_wide(). On unix-likes it's OsStringExt::from_vec() or OsStrExt::from_bytes().

5 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.