ANSI转UTF-8 MFC
CString m_UserName;
DWORD DUserName;
DUserName=::MultiByteToWideChar(CP_ACP,0,m_UserName,-1,NULL,0);
wchar_t* WUserName = new wchar_t[DUserName];
::MultiByteToWideChar( CP_ACP, NULL, m_UserName, -1, WUserName, DUserName );
DWORD uLen = ::WideCharToMultiByte( CP_UTF8, NULL, WUserName,wcslen(WUserName), NULL, 0, NULL, FALSE );
char* uStr = new char[uLen+1];
::WideCharToMultiByte( CP_UTF8, NULL, WUserName,wcslen(WUserName), uStr, uLen, NULL, FALSE );
uStr[uLen] = '\0';
m_UserName.Format("%s",uStr);
delete WUserName;
delete uStr;