I'm trying to get the bytes from a std::wstring and put them into a std::string. Unfortunately, I'm somewhat lacking when it comes to c-style string. I've made this code (and it works), but is there an easier (and more efficient) way?
Thanks.Code:std::string WideStringToStringStrict( const std::wstring& Text ) { unsigned int Size = Text.size() * sizeof( wchar_t ); char* ctemp = new char[Size]; memcpy( ctemp, Text.c_str(), Size ); std::string String; for ( unsigned int i = 0; i < Size; ++i ) String += ctemp[i]; delete[] ctemp; return String; };