Search code examples
stringunicodec++-cliwchar-t

Convert wchar_t* type to managed UTF-8 string


How can I convert wchar_t* type to a managed UTF-8 string in C++/CLI?


Solution

  • Assuming you mean System::String by "managed UTF-8 string" (although managed strings are UTF16) use

    String ^systemstring = gcnew String(YoutrWCharString);
    

    For samples and details see How to: Convert Between Various String Types on MSDN.