Converts GB2312 to UTF8 string Updatemodule::gb2132toutf8 (String strsrc) {string result; WCHAR *wstrsrc = NULL; char *szres = NULL; int i; GB2312 Convert to Unicode i = MultiByteToWideChar (CP_ACP, 0, Strsrc.c_str (),-1, NULL, 0); WSTRSRC = new Wchar[i+1]; MultiByteToWideChar (CP_ACP, 0, Strsrc.c_str (),-1, WSTRSRC, i); Unicode converts to UTF8 i = WideCharToMultiByte (Cp_utf8, 0, Wstrsrc,-1, NULL, 0, NULL, NULL); Szres = new Char[i+1]; WideCharToMultiByte (Cp_utf8, 0, Wstrsrc,-1, szres, I, NULL, NULL); result = string (szres); if (wstrsrc!= null) {delete []wstrsrc; wstrsrc = null;} if (Szres!= NULL) {delete []szres; szres = null;} return res Ult }  Reciprocal conversion functions of; GB2312 and UTF8
Converts UTF8 to GB2312 string utf8togb2132 (String strsrc) {string result; WCHAR *wstrsrc = NULL; char *szres = NULL; int i; UTF8 Convert to Unicode i = MultiByteToWideChar (Cp_utf8, 0, Strsrc.c_str (),-1, NULL, 0); WSTRSRC = new Wchar[i+1]; MultiByteToWideChar (Cp_utf8, 0, Strsrc.c_str (),-1, WSTRSRC, i); Unicode converts to GB2312 i = WideCharToMultiByte (CP_ACP, 0, Wstrsrc,-1, NULL, 0, NULL, NULL); Szres = new Char[i+1]; WideCharToMultiByte (CP_ACP, 0, Wstrsrc,-1, szres, I, NULL, NULL); result = string (szres); if (wstrsrc!= null) {delete []wstrsrc; wstrsrc = null;} if (Szres!= NULL) {delete []szres; szres = null;} return res Ult }