1 /* Compare UTF-8/UTF-16/UTF-32 strings using the collation rules of the current
3 Copyright (C) 2009-2010 Free Software Foundation, Inc.
4 Written by Bruno Haible <bruno@clisp.org>, 2009.
6 This program is free software: you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published
8 by the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 FUNC (const UNIT *s1, const UNIT *s2)
22 /* When this function succeeds, it sets errno back to its original value.
23 When it fails, it sets errno, but also returns a meaningful return value,
24 for the sake of callers which ignore errno. */
25 int final_errno = errno;
30 sl1 = U_STRCONV_TO_LOCALE (s1);
33 sl2 = U_STRCONV_TO_LOCALE (s2);
36 /* Compare sl1 and sl2. */
38 result = strcoll (sl1, sl2);
41 /* strcoll succeeded. */
51 result = U_STRCMP (s1, s2);
56 /* s1 could be converted to locale encoding, s2 not. */
65 sl2 = U_STRCONV_TO_LOCALE (s2);
68 /* s2 could be converted to locale encoding, s1 not. */
74 /* Neither s1 nor s2 could be converted to locale encoding. */
75 result = U_STRCMP (s1, s2);