I am having problem with converting managed System::String to std::string in C++/CLI. This code does not work, I can't understand why:
string SolvingUnitWrapper::getName(String ^name)
{
pin_ptr<const wchar_t> wstr = PtrToStringChars(name);
ostringstream oss;
oss << wstr;
return oss.str();
}
Thanks
System::Stringis a counted sequence of UTF-16 code units. That is, the character set is Unicode and the encoding is UTF-16.std::stringis a counted sequence of char-sized values, without any specific character set or encoding. Before doing anything, you have to decide what target character set and encoding to use. (The thread's default ANSI code page is one option. But, sticking with Unicode and using UTF-8 is increasingly common—that's what System::IO::StreamWriter does.) What's your choice?