1 #include <stdio.h> 2 #include <tchar.h> 3 4 char* UnicodeToAnsi( const wchar_t* szStr ) 5 { 6 int nLen = WideCharToMultiByte( CP_ACP, 0, szStr, -1, NULL, 0, NULL, NULL ); 7 if (nLen == 0) 8 { 9 return NULL; 10 } 11 char* pResult = new char[nLen]; 12 WideCharToMultiByte( CP_ACP, 0, szStr, -1, pResult, nLen, NULL, NULL ); 13 return pResult; 14 } 15 16 void main(){ 17 18 TCHAR msg[100]; 19 swprintf_s(msg, L"sjlkjdkld"); 20 char *str=UnicodeToAnsi(msg); 21 22 }
时间: 2024-11-09 17:43:33