code_junkie

I want to convert std::string into a const wchar_t *

Nov 12th, 2011
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. ::std::string str;
  2. BOOL loadU(const wchar_t* lpszPathName, int flag = 0);
  3.  
  4. loadU(&str);
  5.  
  6. std::wstring name( L"Steve Nash" );
  7. wchar_t* szName = name.c_str();
  8.  
  9. #include <atlconv.h>
  10. ...
  11. std::string str = "Hello, world!";
  12. CA2W pszWide(str.c_str());
  13. loadU(pszWide);
  14.  
  15. CA2W pszWide(str.c_str(), CP_UTF8);
  16.  
  17. std::wstring widestr = std::wstring(str.begin(), str.end());
  18.  
  19. wchar_t* widecstr = widestr.c_str();
Add Comment
Please, Sign In to add comment