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:
parent
60f75e901c
commit
84c93bfba0
@ -15,6 +15,8 @@
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#include <UnicodeChar.h>
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
namespace Storage {
|
||||
@ -192,20 +194,30 @@ StringNode::StringNode(const char *value, bool caseInsensitive)
|
||||
return;
|
||||
|
||||
if (caseInsensitive) {
|
||||
int32 len = strlen(value);
|
||||
for (int32 i = 0; i < len; i++) {
|
||||
char c = value[i];
|
||||
if (isalpha(c)) {
|
||||
int lower = tolower(c);
|
||||
int upper = toupper(c);
|
||||
if (lower < 0 || upper < 0)
|
||||
fValue << c;
|
||||
else
|
||||
fValue << "[" << (char)lower << (char)upper << "]";
|
||||
} else if (c == ' ')
|
||||
while (uint32 codePoint = BUnicodeChar::FromUTF8(&value)) {
|
||||
char utf8Buffer[4];
|
||||
char *utf8 = utf8Buffer;
|
||||
if (BUnicodeChar::IsAlpha(codePoint)) {
|
||||
uint32 lower = BUnicodeChar::ToLower(codePoint);
|
||||
uint32 upper = BUnicodeChar::ToUpper(codePoint);
|
||||
if (lower == upper) {
|
||||
BUnicodeChar::ToUTF8(codePoint, &utf8);
|
||||
fValue.Append(utf8Buffer, utf8 - utf8Buffer);
|
||||
} else {
|
||||
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 << '*';
|
||||
else
|
||||
fValue << c;
|
||||
} else {
|
||||
BUnicodeChar::ToUTF8(codePoint, &utf8);
|
||||
fValue.Append(utf8Buffer, utf8 - utf8Buffer);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fValue = value;
|
||||
|
Loading…
Reference in New Issue
Block a user