]> git.sur5r.net Git - glabels/blob - libglabels/str.c
Organized master branch to be top-level directory for glabels, instead of
[glabels] / libglabels / str.c
1 /*
2  *  str.c
3  *  Copyright (C) 2007-2009  Jim Evins <evins@snaught.com>.
4  *
5  *  This file is part of libglabels.
6  *
7  *  libglabels is free software: you can redistribute it and/or modify
8  *  it under the terms of the GNU Lesser General Public License as published by
9  *  the Free Software Foundation, either version 3 of the License, or
10  *  (at your option) any later version.
11  *
12  *  libglabels is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU Lesser General Public License for more details.
16  *
17  *  You should have received a copy of the GNU Lesser General Public License
18  *  along with libglabels.  If not, see <http://www.gnu.org/licenses/>.
19  */
20
21 #include <config.h>
22
23 #include "str.h"
24
25
26 /*===========================================*/
27 /* Private types                             */
28 /*===========================================*/
29
30
31 /*===========================================*/
32 /* Private globals                           */
33 /*===========================================*/
34
35
36 /*===========================================*/
37 /* Local function prototypes                 */
38 /*===========================================*/
39
40
41 /*===========================================*/
42 /* Functions.                                */
43 /*===========================================*/
44
45 /**
46  * lgl_str_utf8_casecmp:
47  * @s1: string to compare with s2.
48  * @s2: string to compare with s1.
49  *
50  * Compare two UTF-8 strings, ignoring the case of characters.
51  *
52  * This function should be used only on strings that are known to be encoded
53  * in UTF-8 or a compatible UTF-8 subset.
54  *
55  * Returns: 0 if the strings match, a negative value if s1 < s2,
56  *          or a positive value if s1 > s2.
57  *
58  */
59 gint
60 lgl_str_utf8_casecmp (const gchar *s1,
61                       const gchar *s2)
62 {
63         gchar *folded_s1;
64         gchar *folded_s2;
65         gint   result;
66
67         folded_s1 = g_utf8_casefold (s1, -1);
68         folded_s2 = g_utf8_casefold (s2, -1);
69
70         result = g_utf8_collate (folded_s1, folded_s2);
71
72         g_free (folded_s1);
73         g_free (folded_s2);
74
75         return result;
76 }
77
78
79
80 /*
81  * Local Variables:       -- emacs
82  * mode: C                -- emacs
83  * c-basic-offset: 8      -- emacs
84  * tab-width: 8           -- emacs
85  * indent-tabs-mode: nil  -- emacs
86  * End:                   -- emacs
87  */