Mercurial > geeqie.yaz
comparison src/main.c @ 786:a20ff446347e
Compare paths using utf8_collate_key() since paths are utf8-encoded.
It fixes bug 1959854.
author | zas_ |
---|---|
date | Thu, 05 Jun 2008 09:24:42 +0000 |
parents | d6a7fb4b8e7c |
children | baade53888be |
comparison
equal
deleted
inserted
replaced
785:548b193c084c | 786:a20ff446347e |
---|---|
61 len = strlen(text); | 61 len = strlen(text); |
62 if (!g_utf8_validate(text, len, NULL)) | 62 if (!g_utf8_validate(text, len, NULL)) |
63 return g_convert(text, len, "UTF-8", "ISO-8859-1", NULL, NULL, NULL); | 63 return g_convert(text, len, "UTF-8", "ISO-8859-1", NULL, NULL, NULL); |
64 | 64 |
65 return g_strdup(text); | 65 return g_strdup(text); |
66 } | |
67 | |
68 gint utf8_compare(const gchar *s1, const gchar *s2, gboolean case_sensitive) | |
69 { | |
70 gchar *s1_key, *s2_key; | |
71 gchar *s1_t, *s2_t; | |
72 gint ret; | |
73 | |
74 g_assert(g_utf8_validate(s1, -1, NULL)); | |
75 g_assert(g_utf8_validate(s2, -1, NULL)); | |
76 | |
77 if (!case_sensitive) | |
78 { | |
79 s1_t = g_utf8_casefold(s1, -1); | |
80 s2_t = g_utf8_casefold(s2, -1); | |
81 } | |
82 | |
83 s1_key = g_utf8_collate_key(s1_t, -1); | |
84 s2_key = g_utf8_collate_key(s2_t, -1); | |
85 | |
86 ret = strcmp(s1_key, s2_key); | |
87 | |
88 g_free(s1_key); | |
89 g_free(s2_key); | |
90 | |
91 if (!case_sensitive) | |
92 { | |
93 g_free(s1_t); | |
94 g_free(s2_t); | |
95 } | |
96 | |
97 return ret; | |
66 } | 98 } |
67 | 99 |
68 /* Borrowed from gtkfilesystemunix.c */ | 100 /* Borrowed from gtkfilesystemunix.c */ |
69 gchar *expand_tilde(const gchar *filename) | 101 gchar *expand_tilde(const gchar *filename) |
70 { | 102 { |