From 032a570c72570ee7105a5d0c9c21093b2e9b67cc Mon Sep 17 00:00:00 2001 From: waker Date: Tue, 22 Feb 2011 21:15:34 +0100 Subject: case-insensitive utf8 playlist sorting --- utf8.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'utf8.c') diff --git a/utf8.c b/utf8.c index c303b9a1..6249f94a 100644 --- a/utf8.c +++ b/utf8.c @@ -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; -- cgit v1.2.3