网上找了半天,很麻烦,最后弄得了贴出来方便大家: void UnicodeToUtf8( char * utf8) ... { int len = 0; int size_d = 8; DWORD dwNum = MultiByteToWideChar (CP_ACP, 0, utf8, -1, NULL, 0); wchar_t *wchar; wchar = new wchar_t[dwNum]; if(!wchar) ...{ delete []wchar; } MultiByteToWideChar (CP_ACP, 0,utf8, -1, wchar, dwNum); for(int i = 0; i <dwNum; i++) ...{ if ((wchar[i]) < 0x80) ...{ // utf8[len++] = (char)(wchar[i]); } else if((wchar[i]) < 0x800) ...{ utf8[len++] = 0xc0 | ( (*wchar) >> 6 ); utf8[len++] = 0x80 | ( (*wchar) & 0x3f ); } else if((wchar[i]) < 0x10000 ) ...{ utf8[len++] = 0xE0 | ((wchar[i]) >> 12); utf8[len++] = 0x80 | (((wchar[i])>>6) & 0x3F); utf8[len++] = 0x80 | ((wchar[i]) & 0x3F); } else if((wchar[i]) < 0x200000 ) ...{ utf8[len++] = 0xf0 | ( (int)(wchar[i]) >> 18 ); utf8[len++] = 0x80 | ( ((wchar[i]) >> 12) & 0x3f ); utf8[len++] = 0x80 | ( ((wchar[i]) >> 6) & 0x3f ); utf8[len++] = 0x80 | ( (wchar[i]) & 0x3f ); } } } CString UTF8toUnicode( char * s) ... { int len = 0; WCHAR* r = new WCHAR[strlen(s) * 2]; while(s[0]) ...{ int bytes = 1; if(s[0] & 0x80) while(s[0] & (0x80 >> bytes)) bytes++; if(bytes == 1) r[len] = s[0]; else ...{ r[len] = 0; for(char*p = s + (bytes - 1); p > s; p--) r[len] |= ((*p) & 0x3F) << ((bytes - (p - s) - 1) * 6); r[len] |= (s[0] & ((1 << (7 - bytes)) - 1)) << ((bytes - 1) * 6); } len++; s += bytes; } r[len] = 0; char*buffer = new char[len * 2 + 1]; ZeroMemory(buffer, len * 2 + 1); ::WideCharToMultiByte(CP_ACP, NULL, r, len, buffer, 1+ 2 * len, NULL, NULL); CString str = buffer; delete[] r; delete[] buffer; return str; } 能用 具体再自己改