diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 16:56:34 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 16:56:34 +0200 |
commit | 9084fa27f0f43cfa31dbc3a7ef87e2600c2dc3ca (patch) | |
tree | 61e2edc315a164d6fa3940b7de4b14dda0a9838c /library/zstring.cpp | |
parent | 1.15 (diff) | |
download | FreeFileSync-9084fa27f0f43cfa31dbc3a7ef87e2600c2dc3ca.tar.gz FreeFileSync-9084fa27f0f43cfa31dbc3a7ef87e2600c2dc3ca.tar.bz2 FreeFileSync-9084fa27f0f43cfa31dbc3a7ef87e2600c2dc3ca.zip |
1.16
Diffstat (limited to 'library/zstring.cpp')
-rw-r--r-- | library/zstring.cpp | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/library/zstring.cpp b/library/zstring.cpp index 35704b01..27633392 100644 --- a/library/zstring.cpp +++ b/library/zstring.cpp @@ -24,29 +24,23 @@ void testZstringForMemoryLeak() #ifdef FFS_WIN -int FreeFileSync::compareStringsWin32(const wchar_t* a, const wchar_t* b) -{ - return lstrcmpi( - a, //address of first string - b); //address of second string -} - - -//equivalent implementation, but slightly(!!!) slower: int FreeFileSync::compareStringsWin32(const wchar_t* a, const wchar_t* b, const int aCount, const int bCount) { - int rv = CompareString( - LOCALE_USER_DEFAULT, //locale identifier - NORM_IGNORECASE, //comparison-style options - a, //pointer to first string - aCount, //size, in bytes or characters, of first string - b, //pointer to second string - bCount); //size, in bytes or characters, of second string + //DON'T use lstrcmpi() here! It uses word sort, which unfortunately is NOT always a strict weak sorting function for some locales (e.g. swedish) + //Use CompareString() with "SORT_STRINGSORT" instead!!! + + const int rv = CompareString( + LOCALE_USER_DEFAULT, //locale identifier + NORM_IGNORECASE | SORT_STRINGSORT, //comparison-style options + a, //pointer to first string + aCount, //size, in bytes or characters, of first string + b, //pointer to second string + bCount); //size, in bytes or characters, of second string if (rv == 0) throw RuntimeException(wxString(wxT("Error comparing strings!"))); else - return rv - 2; + return rv - 2; //convert to C-style string compare result } #endif |