Skip to content

Instantly share code, notes, and snippets.

@SeanCline
Last active August 25, 2016 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SeanCline/726b43a1c91928dfc34439f26369e6b2 to your computer and use it in GitHub Desktop.
Save SeanCline/726b43a1c91928dfc34439f26369e6b2 to your computer and use it in GitHub Desktop.
#pragma once
#include <string>
// Why can't MFC and ATL just get along?
#if defined(_AFX) || defined(_AFXDLL)
# include <cstringt.h>
#else
# include <atlstr.h>
#endif
/*
* @breif Converts an CStringW (Wide CString) to a std::wstring.
*/
inline std::wstring to_wstring(const CStringW& from)
{
return std::wstring(static_cast<const wchar_t*>(from), from.GetLength());
}
/*
* @breif Converts an CStringA (Ansi CString) to a std::wstring.
*/
inline std::wstring to_wstring(const CStringA& from)
{
return to_wstring(CStringW(from));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment