BOOL EncodingHandler::MByteToWChar(LPCSTR lpcszStr, LPWSTR lpwszStr, int dwMultiSize) { // Convert headers from ASCII to Unicode. //chenjian_unicode 后需要改添加if的条件 UINT acp = GetACP(); memset(lpwszStr, 0, dwMultiSize * 2); if(UINT(936) == acp) { MultiByteToWideChar (CP_ACP, NULL, lpcszStr, -1, lpwszStr, dwMultiSize); } else { MultiByteToWideChar(936, NULL, lpcszStr, -1, lpwszStr, dwMultiSize); //936 } return TRUE; } BOOL EncodingHandler::WCharToMByte(LPCWSTR lpcwszStr, LPSTR lpszStr, int dwMultiSize) { // Convert headers from Unicode to ASCII. memset(lpszStr, 0, dwMultiSize); WideCharToMultiByte (CP_OEMCP, NULL, lpcwszStr, -1, lpszStr, dwMultiSize,NULL,FALSE); return TRUE; } BOOL EncodingHandler::UTF8ByteToWChar(LPCSTR lpcszStr, LPWSTR lpwszStr, int dwMultiSize) { // Get the required size of the buffer that receives the Unicode // string. DWORD dwMinSize; memset(lpwszStr, 0, dwMultiSize * 2); dwMinSize = MultiByteToWideChar (CP_UTF8, 0, lpcszStr, -1, NULL, 0); if(dwMultiSize < dwMinSize) { return FALSE; } // Convert headers from UTF8 to Unicode. MultiByteToWideChar (CP_UTF8, 0, lpcszStr, dwMultiSize, lpwszStr, dwMinSize); return TRUE; } BOOL EncodingHandler::WCharToUTF8Byte(LPCWSTR lpcwszStr, LPSTR lpszStr, int dwMultiSize) { // Convert headers from Unicode to UTF8. memset(lpszStr, 0, dwMultiSize); WideCharToMultiByte (CP_UTF8, NULL, lpcwszStr, -1, lpszStr, dwMultiSize,NULL,FALSE); return TRUE; }
const BOOL ListView::C2TC(const char * c, PTCHAR tc,DWORD dwSize) { #if defined(UNICODE) UINT acp = GetACP(); if(UINT(936) == acp)//后续要改,添加if条件 { MultiByteToWideChar(CP_ACP, 0, c, -1, tc, strlen(c)); tc[strlen(c)] = 0; } else{ C2TC_AnsiUTF8Document(c, tc, dwSize); } #else lstrcpy((PTSTR)tc, (PTSTR)c); #endif return TRUE; } const BOOL ListView::TC2C(const PTCHAR tc, char * c,DWORD dwSize) { DWORD dwMinSize; dwMinSize = WideCharToMultiByte(GetACP(),NULL,tc,-1,NULL,0,NULL,FALSE); if(dwSize < dwMinSize) { return FALSE; } WideCharToMultiByte(GetACP(),NULL,tc,-1,c,dwSize,NULL,FALSE); return TRUE; } const BOOL ListView::C2TC_AnsiUTF8Document(const char * c, PTCHAR tc,DWORD dwSize) { int wcsLen = MultiByteToWideChar(936, NULL, c, strlen(c), NULL, 0); //936 MultiByteToWideChar(936, NULL, c, strlen(c), tc, wcsLen); //936 tc[wcsLen] = 0; return TRUE; } //const BOOL ListView::TC2C_AnsiDocument(const PTCHAR tc, char * c,DWORD dwSize) //{ // int ansiLen = WideCharToMultiByte(GetACP(), NULL, tc, wcslen(tc), NULL, 0, NULL, NULL); // WideCharToMultiByte(GetACP(), NULL, tc, wcslen(tc), c, ansiLen, NULL, NULL); // return TRUE; //} const BOOL ListView::TC2C_UTF8Document(const PTCHAR tc, char * c,DWORD dwSize) { //int ansiLen = WideCharToMultiByte(936, NULL, wszStringSource, wcslen(wszStringSource), NULL, 0, NULL, NULL); //char* szAnsi = new char[ansiLen + 1]; //WideCharToMultiByte(936, NULL, wszStringSource, wcslen(wszStringSource), szAnsi, ansiLen, NULL, NULL); //szAnsi[ansiLen] = '\0'; //szAnsi = 0x00547bf8 "Äã" char* old_locale = _strdup( setlocale(LC_CTYPE,NULL) ); setlocale( LC_CTYPE, "chs" ); sprintf(c,"%S",tc); setlocale( LC_CTYPE, old_locale ); delete old_locale;//还原区域设定 return TRUE; } // //const BOOL ListView::UTF82TC_UTF8Document(const char * c, PTCHAR tc,DWORD dwSize) //{ // EncodingHandler::UTF8ByteToWChar( c, tc, dwSize); // return TRUE; //} //const BOOL ListView::TC2UTF8_UTF8Document(const PTCHAR tc, char * c,DWORD dwSize) //{ // int u8Len = WideCharToMultiByte(CP_UTF8, NULL, tc, wcslen(tc), NULL, 0, NULL, NULL); // // unicode to UTF8 // EncodingHandler::WCharToUTF8Byte(tc, c, u8Len); // return TRUE; //} //chenjian_unicode add end
1) BlockManager.cpp 含有中文字符 自选股
TradeObject.cpp中含有中文字符 万亿
在英文系统下将乱码修改
2)修改代码
BlockManager.cpp
ListView.cpp
QuotesListView.cpp
EncodingHandler.cpp
ListView.h