1、Unicode转UTF-8

 1 void CodeCovertTool::UNICODE_to_UTF8(const CString& unicodeString, std::string& str)
 2 {//Unicode转UTF8
 3     int stringLength = ::WideCharToMultiByte(CP_UTF8, NULL, unicodeString, wcslen(unicodeString), NULL, 0, NULL, NULL);
 4 
 5     char* buffer = new char[stringLength + 1];
 6     ::WideCharToMultiByte(CP_UTF8, NULL, unicodeString, wcslen(unicodeString), buffer, stringLength, NULL, NULL);
 7     buffer[stringLength] = '\0';
 8 
 9     str = buffer;
10 
11     delete[] buffer;
12 }
View Code

相关文章: