1 /* Case and normalization insensitive comparison of Unicode strings.
2 Copyright (C) 2009-2012 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2009.
5 This program is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Lesser General Public License as published
7 by the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 FUNC (const SRC_UNIT *s1, size_t n1, const SRC_UNIT *s2, size_t n2,
20 const char *iso639_language, uninorm_t nf, int *resultp)
22 UNIT buf1[2048 / sizeof (UNIT)];
23 UNIT buf2[2048 / sizeof (UNIT)];
30 /* Optimization: There is no need to do canonical composition of each string.
31 Decomposition is enough. */
33 nf = uninorm_decomposing_form (nf);
35 /* Case-fold and normalize S1. */
36 norms1_length = sizeof (buf1) / sizeof (UNIT);
37 norms1 = U_CASEFOLD (s1, n1, iso639_language, nf, buf1, &norms1_length);
39 /* errno is set here. */
42 /* Case-fold and normalize S2. */
43 norms2_length = sizeof (buf2) / sizeof (UNIT);
44 norms2 = U_CASEFOLD (s2, n2, iso639_language, nf, buf2, &norms2_length);
49 int saved_errno = errno;
56 /* Compare the normalized strings. */
57 cmp = U_CMP2 (norms1, norms1_length, norms2, norms2_length);