diff options
author | waker <wakeroid@gmail.com> | 2011-02-22 21:15:34 +0100 |
---|---|---|
committer | waker <wakeroid@gmail.com> | 2011-02-22 21:15:34 +0100 |
commit | 032a570c72570ee7105a5d0c9c21093b2e9b67cc (patch) | |
tree | 4c1cd201696f7bfeb511b41776f8979492403946 /utf8.c | |
parent | 95be34c4fcb9e52a1d7fc5dbe36005c1adbd4593 (diff) |
case-insensitive utf8 playlist sorting
Diffstat (limited to 'utf8.c')
-rw-r--r-- | utf8.c | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -688,6 +688,34 @@ utfcasestr (const char *s1, const char *s2) { return NULL; } +int +u8_strcasecmp (const char *a, const char *b) { + const char *p1 = a, *p2 = b; + while (*p1 && *p2) { + int32_t i1 = 0; + int32_t i2 = 0; + char s1[10], s2[10]; + const char *next; + u8_nextchar (p1, &i1); + u8_nextchar (p2, &i2); + int l1 = u8_tolower (p1, i1, s1); + int l2 = u8_tolower (p2, i2, s2); + int res = 0; + if (l1 != l2) { + res = l1-l2; + } + else { + res = memcmp (s1, s2, l1); + } + if (res) { + return res; + } + p1 += i1; + p2 += i2; + } + return 0; +} + void u8_lc_map_test (void) { struct u8_case_map_t *lc; |