lib/icu/Compare: add Windows implementation

Using CompareStringEx() and FindNLSStringEx().

Implements a missing piece for
https://github.com/MusicPlayerDaemon/MPD/issues/820
This commit is contained in:
Max Kellermann
2020-04-22 19:43:29 +02:00
parent f3fd2eb618
commit 8f00dbea45
2 changed files with 60 additions and 0 deletions

View File

@@ -23,13 +23,23 @@
#include "util/Compiler.h"
#include "util/AllocatedString.hxx"
#ifdef _WIN32
#include <wchar.h>
#endif
/**
* This class can compare one string ("needle") with lots of other
* strings ("haystacks") efficiently, ignoring case. With some
* configurations, it can prepare a case-folded version of the needle.
*/
class IcuCompare {
#ifdef _WIN32
/* Windows API functions work with wchar_t strings, so let's
cache the MultiByteToWideChar() result for performance */
AllocatedString<wchar_t> needle;
#else
AllocatedString<> needle;
#endif
public:
IcuCompare():needle(nullptr) {}