1STD::string& Msgfieldlist::gbtoutf8 (std::string& Des,Const Char*str)2 {3WCHAR *strsrc;4TCHAR *Szres;5 6 //get the size of a temporary variable7 inti = MultiByteToWideChar (CP_ACP,0, str,-1Null0);8STRSRC =Newwchar[i+1];9MultiByteToWideChar (CP_ACP,0, str,-1, STRSRC, i);Ten One //get the size of a temporary variable Ai = WideCharToMultiByte (Cp_utf8,0, STRSRC,-1Null0, NULL, NULL); -Szres =Newtchar[i+1]; - intJ=widechartomultibyte (Cp_utf8,0, STRSRC,-1, szres, I, NULL, NULL); the -Des =Szres; - Delete[]strsrc; - Delete[]szres; + - returndes; +}
Reverse Code:
1STD::string& MSGFIELDLIST::UTF8TOGB (std::string& Des,Const Char*str)2 {3WCHAR *strsrc;4TCHAR *Szres;5 6 //get the size of a temporary variable7 inti = MultiByteToWideChar (Cp_utf8,0, str,-1Null0);8STRSRC =Newwchar[i+1];9MultiByteToWideChar (Cp_utf8,0, str,-1, STRSRC, i);Ten One //get the size of a temporary variable Ai = WideCharToMultiByte (CP_ACP,0, STRSRC,-1Null0, NULL, NULL); -Szres =Newtchar[i+1]; -WideCharToMultiByte (CP_ACP,0, STRSRC,-1, szres, I, NULL, NULL); the -Des =Szres; - Delete[]strsrc; - Delete[]szres; + - returndes; +}
Functions about transcoding under Windows