How to convert Platform::String to char*?

后端 未结 5 1280
长情又很酷
长情又很酷 2020-12-01 23:53

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 ju

5条回答
  •  遥遥无期
    2020-12-02 00:26

    A solution using wcstombs:

    Platform::String^ platform_string = p_e->Uri->AbsoluteUri;
    const wchar_t* wide_chars =  platform_string->Data();
    char chars[512];
    wcstombs(chars, wide_chars, 512);
    

提交回复
热议问题