2 .\" Copyright (c) 2007, Sun Microsystems Inc. All Rights Reserved.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH U8_STRCMP 3C "Sep 12, 2007"
8 u8_strcmp \- UTF-8 string comparison function
12 #include <sys/u8_textprep.h>
14 \fBint\fR \fBu8_strcmp\fR(\fBconst char *\fR\fIs1\fR, \fBconst char *\fR\fIs2\fR, \fBsize_t\fR \fIn\fR,
15 \fBint\fR \fIflag\fR, \fBsize_t\fR \fIversion\fR, \fBint *\fR\fIerrnum\fR);
22 \fB\fIs1\fR, \fIs2\fR\fR
25 Pointers to null-terminated UTF-8 strings
34 The maximum number of bytes to be compared. If 0, the comparison is performed
35 until either or both of the strings are examined to the string terminating null
45 The possible comparison options constructed by a bit-wise-inclusive-OR of the
50 \fB\fBU8_STRCMP_CS\fR\fR
54 Perform case-sensitive string comparison. This is the default.
60 \fB\fBU8_STRCMP_CI_UPPER\fR\fR
64 Perform case-insensitive string comparison based on Unicode upper case
65 converted results of \fIs1\fR and \fIs2\fR.
71 \fB\fBU8_STRCMP_CI_LOWER\fR\fR
75 Perform case-insensitive string comparison based on Unicode lower case
76 converted results of \fIs1\fR and \fIs2\fR.
82 \fB\fBU8_STRCMP_NFD\fR\fR
86 Perform string comparison after \fIs1\fR and \fIs2\fR have been normalized by
87 using Unicode Normalization Form D.
93 \fB\fBU8_STRCMP_NFC\fR\fR
97 Perform string comparison after \fIs1\fR and \fIs2\fR have been normalized by
98 using Unicode Normalization Form C.
104 \fB\fBU8_STRCMP_NFKD\fR\fR
108 Perform string comparison after \fIs1\fR and \fIs2\fR have been normalized by
109 using Unicode Normalization Form KD.
115 \fB\fBU8_STRCMP_NFKC\fR\fR
119 Perform string comparison after \fIs1\fR and \fIs2\fR have been normalized by
120 using Unicode Normalization Form KC.
123 Only one case-sensitive or case-insensitive option is allowed. Only one Unicode
124 Normalization option is allowed.
133 The version of Unicode data that should be used during comparison. The
134 following values are supported:
138 \fB\fBU8_UNICODE_320\fR\fR
142 Use Unicode 3.2.0 data during comparison.
148 \fB\fBU8_UNICODE_500\fR\fR
152 Use Unicode 5.0.0 data during comparison.
158 \fB\fBU8_UNICODE_LATEST\fR\fR
162 Use the latest Unicode version data available, which is Unicode 5.0.0.
173 A non-zero value indicates that an error has occurred during comparison. The
174 following values are supported:
181 The specified option values are conflicting and cannot be supported.
190 There was an illegal character at \fIs1\fR, \fIs2\fR, or both.
199 There was an incomplete character at \fIs1\fR, \fIs2\fR, or both.
208 The specified Unicode version value is not supported.
216 The \fBu8_stcmp()\fR function internally processes UTF-8 strings pointed to by
217 \fIs1\fR and \fIs2\fR based on the corresponding version of the Unicode
218 Standard and other input arguments and compares the result strings in
219 byte-by-byte, machine ordering.
222 When multiple comparison options are specified, Unicode Normalization is
223 performed after case-sensitive or case-insensitive processing is performed.
227 The \fBu8_strcmp()\fR function returns an integer greater than, equal to, or
228 less than 0 if the string pointed to by \fIs1\fR is greater than, equal to, or
229 less than the string pointed to by \fIs2\fR, respectively.
232 When \fBu8_strcmp()\fR detects an illegal or incomplete character, such
233 character causes the function to set \fIerrnum\fR to indicate the error.
234 Afterward, the comparison is still performed on the resultant strings and a
235 value based on byte-by-byte comparison is always returned.
238 \fBExample 1 \fRPerform simple default string comparison.
242 #include <sys/u8_textprep.h>
245 docmp_default(const char *u1, const char *u2) {
249 result = u8_strcmp(u1, u2, 0, 0, U8_UNICODE_LATEST, &errnum);
250 if (errnum == EILSEQ)
252 if (errnum == EINVAL)
256 if (errnum == ERANGE)
262 \fBExample 2 \fRPerform upper case based case-insensitive comparison with
267 #include <sys/u8_textprep.h>
270 docmp_caseinsensitive_u320(const char *u1, const char *u2) {
274 result = u8_strcmp(u1, u2, 0, U8_STRCMP_CI_UPPER,
275 U8_UNICODE_320, &errnum);
276 if (errnum == EILSEQ)
278 if (errnum == EINVAL)
282 if (errnum == ERANGE)
291 \fBExample 3 \fRPerform Unicode Normalization Form D.
294 Perform Unicode Normalization Form D and upper case based case-insensitive
295 comparison with Unicode 3.2.0 date.
300 #include <sys/u8_textprep.h>
303 docmp_nfd_caseinsensitive_u320(const char *u1, const char *u2) {
307 result = u8_strcmp(u1, u2, 0,
308 (U8_STRCMP_NFD|U8_STRCMP_CI_UPPER), U8_UNICODE_320,
310 if (errnum == EILSEQ)
312 if (errnum == EINVAL)
316 if (errnum == ERANGE)
327 See \fBattributes\fR(5) for descriptions of the following attributes:
335 ATTRIBUTE TYPE ATTRIBUTE VALUE
337 Interface Stability Committed
345 \fBu8_textprep_str\fR(3C), \fBu8_validate\fR(3C), \fBattributes\fR(5),
346 \fBu8_strcmp\fR(9F), \fBu8_textprep_str\fR(9F), \fBu8_validate\fR(9F)
349 The Unicode Standard (http://www.unicode.org)