How do I convert the contents of a Platform::String to be used by functions that expect a char* based string? I’m assuming WinRT provides helper functions for this but I just can’t find them.
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Platform::String::Data()will return awchar_t const*pointing to the contents of the string (similar tostd::wstring::c_str()).Platform::Stringrepresents an immutable string, so there’s no accessor to get awchar_t*. You’ll need to copy its contents, e.g. into astd::wstring, to make changes.There’s no direct way to get a
char*or achar const*becausePlatform::Stringuses wide characters (all Metro style apps are Unicode apps). You can convert to multibyte usingWideCharToMultiByte.