Attempt at #1586 (queries not being case-insensitive for umlauts):

* adjust corresponding query predicate to use BUnicodeChar instead
  of ctype-functions

Alas, this does not help as of now, since BUnicodeChar is missing
support for any codepoints above 0x9f ...
This commit is contained in:
Oliver Tappe
2012-04-04 22:54:08 +02:00
parent 60f75e901c
commit 84c93bfba0
+25 -13
View File
@@ -15,6 +15,8 @@
#include <ctype.h> #include <ctype.h>
#include <UnicodeChar.h>
namespace BPrivate { namespace BPrivate {
namespace Storage { namespace Storage {
@@ -192,20 +194,30 @@ StringNode::StringNode(const char *value, bool caseInsensitive)
return; return;
if (caseInsensitive) { if (caseInsensitive) {
int32 len = strlen(value); while (uint32 codePoint = BUnicodeChar::FromUTF8(&value)) {
for (int32 i = 0; i < len; i++) { char utf8Buffer[4];
char c = value[i]; char *utf8 = utf8Buffer;
if (isalpha(c)) { if (BUnicodeChar::IsAlpha(codePoint)) {
int lower = tolower(c); uint32 lower = BUnicodeChar::ToLower(codePoint);
int upper = toupper(c); uint32 upper = BUnicodeChar::ToUpper(codePoint);
if (lower < 0 || upper < 0) if (lower == upper) {
fValue << c; BUnicodeChar::ToUTF8(codePoint, &utf8);
else fValue.Append(utf8Buffer, utf8 - utf8Buffer);
fValue << "[" << (char)lower << (char)upper << "]"; } else {
} else if (c == ' ') fValue << "[";
BUnicodeChar::ToUTF8(lower, &utf8);
fValue.Append(utf8Buffer, utf8 - utf8Buffer);
utf8 = utf8Buffer;
BUnicodeChar::ToUTF8(upper, &utf8);
fValue.Append(utf8Buffer, utf8 - utf8Buffer);
fValue << "]";
}
} else if (codePoint == L' ') {
fValue << '*'; fValue << '*';
else } else {
fValue << c; BUnicodeChar::ToUTF8(codePoint, &utf8);
fValue.Append(utf8Buffer, utf8 - utf8Buffer);
}
} }
} else { } else {
fValue = value; fValue = value;