diff options
Diffstat (limited to 'src/core/wee-utf8.c')
-rw-r--r-- | src/core/wee-utf8.c | 37 |
1 files changed, 6 insertions, 31 deletions
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); } /* |