Last active
January 29, 2016 08:22
-
-
Save DevStarSJ/c68e55449dc6e68d7376 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::string S2(CString& CS) | |
{ | |
#ifdef _UNICODE | |
USES_CONVERSION; | |
std::string S = W2A(CS.GetBuffer()); | |
#else | |
std::string S = CS.GetBuffer(); | |
#endif | |
return S; | |
} | |
CString S2(std::string& S) | |
{ | |
#ifdef _UNICODE | |
USES_CONVERSION; | |
CString CS = A2W(S.c_str()); | |
#else | |
CString CS = S.c_str(); | |
#endif | |
return CS; | |
} | |
CString S2(std::wstring& WS) | |
{ | |
#ifdef _UNICODE | |
CString CS = WS.c_str(); | |
#else | |
USES_CONVERSION; | |
CString CS = W2A(WS.c_str()); | |
#endif | |
return CS; | |
} | |
std::string S3(std::wstring& WS) | |
{ | |
USES_CONVERSION; | |
return std::string(WA2(WS.c_str())); | |
} | |
std::wstring S3(std::string& S) | |
{ | |
USES_CONVERSION; | |
return std::wstring(A2W(S.c_str())); | |
} | |
LPSTR S4_LPSTR(TCHAR * pChar) | |
{ | |
#ifdef _UNICODE | |
return (LPSTR)S3(std::wstring(pChar)).c_str(); | |
#else | |
return (LPSTR)pChar; | |
#endif | |
} | |
LPTSTR S4_LPTSTR(char * pChar) | |
{ | |
return (LPTSTR)S3(std::string(pChar)).c_str(); | |
} | |
LPTSTR S4_LPTSTR(wchar_t * pChar) | |
{ | |
return (LPTSTR)pChar; | |
} | |
LPCSTR S4_LPCSTR(TCHAR * pChar) | |
{ | |
return (LPCSTR)S4_LPSTR(pChar); | |
} | |
LPCTSTR S4_LPCTSTR(TCHAR * pChar) | |
{ | |
#ifdef _UNICODE | |
return (LPCTSTR)pChar; | |
#else | |
return (LPCTSTR)S4_LPTSTR(pChar); | |
#endif | |
} | |
void SMEMCPY(char* destBuf, CString & strSrc, int nSize) | |
{ | |
std::string str = CWVString::S2(strSrc); | |
ZeroMemory(destBuf, nSize); | |
memcpy(destBuf, &str[0], min(str.size(), (size_t)(nSize - 1))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment