summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/wee-string.c4
-rw-r--r--src/core/wee-utf8.c37
2 files changed, 8 insertions, 33 deletions
diff --git a/src/core/wee-string.c b/src/core/wee-string.c
index 44f8c1e04..2bf09bc3a 100644
--- a/src/core/wee-string.c
+++ b/src/core/wee-string.c
@@ -235,7 +235,7 @@ string_strcasestr (const char *string, const char *search)
{
int length_search;
- length_search = strlen (search);
+ length_search = utf8_strlen (search);
if (!string || !search || (length_search == 0))
return NULL;
@@ -245,7 +245,7 @@ string_strcasestr (const char *string, const char *search)
if (string_strncasecmp (string, search, length_search) == 0)
return (char *)string;
- string++;
+ string = utf8_next_char (string);
}
return NULL;
diff --git a/src/core/wee-utf8.c b/src/core/wee-utf8.c
index 73ecf1d72..17f6c20c6 100644
--- a/src/core/wee-utf8.c
+++ b/src/core/wee-utf8.c
@@ -410,43 +410,18 @@ utf8_charcmp (const char *string1, const char *string2)
int
utf8_charcasecmp (const char *string1, const char *string2)
{
- int length1, length2, i, char1, char2, diff;
+ wchar_t wstring1[2], wstring2[2];
if (!string1 || !string2)
return (string1) ? 1 : ((string2) ? -1 : 0);
- length1 = utf8_char_size (string1);
- length2 = utf8_char_size (string2);
-
- char1 = (int)((unsigned char) string1[0]);
- char2 = (int)((unsigned char) string2[0]);
-
- if ((char1 >= 'A') && (char1 <= 'Z'))
- char1 += ('a' - 'A');
-
- if ((char2 >= 'A') && (char2 <= 'Z'))
- char2 += ('a' - 'A');
+ memset (wstring1, 0, sizeof (wstring1));
+ memset (wstring2, 0, sizeof (wstring2));
- diff = char1 - char2;
- if (diff != 0)
- return diff;
+ mbstowcs (wstring1, string1, 1);
+ mbstowcs (wstring2, string2, 1);
- i = 1;
- while ((i < length1) && (i < length2))
- {
- diff = (int)((unsigned char) string1[i]) - (int)((unsigned char) string2[i]);
- if (diff != 0)
- return diff;
- i++;
- }
- /* string1 == string2 ? */
- if ((i == length1) && (i == length2))
- return 0;
- /* string1 < string2 ? */
- if (i == length1)
- return 1;
- /* string1 > string2 */
- return -1;
+ return wcscasecmp (wstring1, wstring2);
}
/*