标签:
WCHAR * mbcsToUnicode(const char *zStr) { int nByte; WCHAR *zMbcsStr; int codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP; nByte = MultiByteToWideChar(codepage, 0, zStr, -1, NULL,0)*sizeof(WCHAR); zMbcsStr = (WCHAR*)malloc( nByte*sizeof(zMbcsStr[0]) ); if( zMbcsStr==0 ) { return 0; } nByte = MultiByteToWideChar(codepage, 0, zStr, -1, zMbcsStr, nByte); if( nByte==0 ) { free(zMbcsStr); zMbcsStr = 0; } return zMbcsStr; } BOOL CompareStr(CStringA S1, CStringA S2) { WCHAR* wa; WCHAR* wb; wa = mbcsToUnicode(S1.GetBuffer()); wb = mbcsToUnicode(S2.GetBuffer()); return CompareStringW(LOCALE_USER_DEFAULT, NORM_IGNORECASE, (LPCWSTR)wa, wcslen(wa), (LPCWSTR)wb, wcslen(wb)) - CSTR_EQUAL == 1; }
参考:http://blog.csdn.net/dbyoung/article/details/7716086
标签:
原文地址:http://www.cnblogs.com/findumars/p/4634448.html