-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add OsStringExt::from_wide_ptr for windows #36671
Conversation
…char_t* null-terminated strings)
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @aturon (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Thanks for the PR! I'd feel a little uneasy about adding this as I think it's conflating the concept of a "C wide string" and an "OS string". For the standard library an OS string does not guarantee nor require a trailing nul, but a C string does (as do wide C strings). In some sense I think we may want a That's a pretty weighty addition, though, so we may not want to tackle it just yet. Thoughts from others on @rust-lang/libs? |
Most of the time, when getting strings from windows API, you usually provide the buffer yourself. It is somewhat rare for Windows API to return a pointer to a buffer that you don't own. If anything, a |
@alexcrichton |
@alexcrichton I agree that, in terms of fitting with existing std practice, we'd want to isolate a separate |
Would this This sounds like a perfect opportunity for someone _cough_ to flesh out the design in an external crate and then have an RFC to merge it into std. |
Ok. I'm starting to write RFC for CWideString. It will take some time. |
Ok, I'm gonna close this in favor of a future pending RFC, but thanks regardless for the PR @bozaro! |
Sorry for a long delay, but I created RFC: rust-lang/rfcs#1773 |
Thanks @bozaro! |
This method is like CStr::from_ptr for wchar_t* null-terminated strings