Created
March 30, 2015 13:16
-
-
Save ajchemist/f5b98be581009a400d35 to your computer and use it in GitHub Desktop.
MFC utilities
This file contains hidden or 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
| char* ConvertUnicodeToMultybyte(CString strUnicode) | |
| { | |
| int nLen = WideCharToMultiByte(CP_ACP, 0, strUnicode, -1, NULL, 0, NULL, NULL); | |
| char* pMultibyte = new char[nLen]; | |
| memset(pMultibyte, 0x00, (nLen)*sizeof(char)); | |
| WideCharToMultiByte(CP_ACP, 0, strUnicode, -1, pMultibyte, nLen, NULL, NULL); | |
| return pMultibyte; | |
| } | |
| CString ConvertMultibyteToUnicode(char* pMultibyte) | |
| { | |
| int nLen = strlen(pMultibyte); | |
| WCHAR *pWideChar = new WCHAR[nLen]; | |
| memset(pWideChar, 0x00, (nLen)*sizeof(WCHAR)); | |
| MultiByteToWideChar(CP_ACP, 0, (LPCSTR)pMultibyte, -1, pWideChar, nLen); | |
| CString strUnicode; | |
| strUnicode.Format(_T("%s"), pWideChar); | |
| delete [] pWideChar; | |
| return strUnicode; | |
| } | |
| CString strUnicode(_T("유니코드")); | |
| char* pMultibyte = ConvertUnicodeToMultibyte(strUnicode); | |
| char* pMultibyte = "멀티바이트"; | |
| CString strUnicode = ConvertMultibyteToUnicode(pMultibyte); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment