nightly: remove unused BINARCHIVE
[unleashed.git] / share / man / man9f / u8_strcmp.9f
blob21317fae5a0bab2fda563fd1db4a318b153b74b8
1 '\" te
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 9F "Sep 18, 2007"
7 .SH NAME
8 u8_strcmp \- UTF-8 string comparison function
9 .SH SYNOPSIS
10 .LP
11 .nf
12 #include <sys/sunddi.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 \fIunicode_version\fR, \fBint *\fR\fIerrno\fR);
16 .fi
18 .SH INTERFACE LEVEL
19 .sp
20 .LP
21 Solaris DDI specific (Solaris DDI)
22 .SH PARAMETERS
23 .sp
24 .ne 2
25 .na
26 \fB\fIs1\fR, \fIs2\fR\fR
27 .ad
28 .RS 20n
29 Pointers to null-terminated UTF-8 strings
30 .RE
32 .sp
33 .ne 2
34 .na
35 \fB\fIn\fR\fR
36 .ad
37 .RS 20n
38 The maximum number of bytes to be compared.  If 0, the comparison is performed
39 until either or both of the strings are examined to the string terminating null
40 byte.
41 .RE
43 .sp
44 .ne 2
45 .na
46 \fB\fIflag\fR\fR
47 .ad
48 .RS 20n
49 The possible comparison options constructed by a bit-wise-inclusive-OR of the
50 following values:
51 .sp
52 .ne 2
53 .na
54 \fB\fBU8_STRCMP_CS\fR\fR
55 .ad
56 .sp .6
57 .RS 4n
58 Perform case-sensitive string comparison. This is the default.
59 .RE
61 .sp
62 .ne 2
63 .na
64 \fB\fBU8_STRCMP_CI_UPPER\fR\fR
65 .ad
66 .sp .6
67 .RS 4n
68 Perform case-insensitive string comparison based on Unicode upper case
69 converted results of \fIs1\fR and \fIs2\fR.
70 .RE
72 .sp
73 .ne 2
74 .na
75 \fB\fBU8_STRCMP_CI_LOWER\fR\fR
76 .ad
77 .sp .6
78 .RS 4n
79 Perform case-insensitive string comparison based on Unicode lower case
80 converted results of \fIs1\fR and \fIs2\fR.
81 .RE
83 .sp
84 .ne 2
85 .na
86 \fB\fBU8_STRCMP_NFD\fR\fR
87 .ad
88 .sp .6
89 .RS 4n
90 Perform string comparison after \fIs1\fR and \fIs2\fR have been normalized by
91 using Unicode Normalization Form D.
92 .RE
94 .sp
95 .ne 2
96 .na
97 \fB\fBU8_STRCMP_NFC\fR\fR
98 .ad
99 .sp .6
100 .RS 4n
101 Perform string comparison after \fIs1\fR and \fIs2\fR have been normalized by
102 using Unicode Normalization Form C.
106 .ne 2
108 \fB\fBU8_STRCMP_NFKD\fR\fR
110 .sp .6
111 .RS 4n
112 Perform string comparison after \fIs1\fR and \fIs2\fR have been normalized by
113 using Unicode Normalization Form KD.
117 .ne 2
119 \fB\fBU8_STRCMP_NFKC\fR\fR
121 .sp .6
122 .RS 4n
123 Perform string comparison after \fIs1\fR and \fIs2\fR have been normalized by
124 using Unicode Normalization Form KC.
127 Only one case-sensitive or case-insensitive option is allowed. Only one Unicode
128 Normalization option is allowed.
132 .ne 2
134 \fB\fIunicode_version\fR\fR
136 .RS 20n
137 The version of Unicode data that should be used during comparison. The
138 following values are supported:
140 .ne 2
142 \fB\fBU8_UNICODE_320\fR\fR
144 .sp .6
145 .RS 4n
146 Use Unicode 3.2.0 data during comparison.
150 .ne 2
152 \fB\fBU8_UNICODE_500\fR\fR
154 .sp .6
155 .RS 4n
156 Use Unicode 5.0.0 data during comparison.
160 .ne 2
162 \fB\fBU8_UNICODE_LATEST\fR\fR
164 .sp .6
165 .RS 4n
166 Use the latest Unicode version data available, which is Unicode 5.0.0.
172 .ne 2
174 \fB\fIerrno\fR\fR
176 .RS 20n
177 A non-zero value indicates that an error has occurred during comparison. The
178 following values are supported:
180 .ne 2
182 \fB\fBEBADF\fR\fR
184 .RS 10n
185 The specified option values are conflicting and cannot be supported.
189 .ne 2
191 \fB\fBEILSEQ\fR\fR
193 .RS 10n
194 There was an illegal character at \fIs1\fR, \fIs2\fR, or both.
198 .ne 2
200 \fB\fBEINVAL\fR\fR
202 .RS 10n
203 There was an incomplete character at \fIs1\fR, \fIs2\fR, or both.
207 .ne 2
209 \fB\fBERANGE\fR\fR
211 .RS 10n
212 The specified Unicode version value is not supported.
217 .SH DESCRIPTION
220 After proper pre-processing, the \fBu8_strcmp()\fR function compares two UTF-8
221 strings byte-by-byte, according to the machine ordering defined by the
222 corresponding version of the Unicode Standard.
225 When multiple comparison options are specified, Unicode Normalization is
226 performed after case-sensitive or case-insensitive processing is performed.
227 .SH RETURN VALUES
230 The \fBu8_strcmp()\fR function returns an integer greater than, equal to, or
231 less than 0 if the string pointed to by \fIs1\fR is greater than, equal to, or
232 less than the string pointed to by \fIs2\fR, respectively.
235 When \fBu8_strcmp()\fR detects an illegal or incomplete character, such
236 character causes the function to set \fIerrno\fR to indicate the error.
237 Afterward, the comparison is still performed on the resultant strings and a
238 value based on byte-by-byte comparison is always returned.
239 .SH CONTEXT
242 The \fBu8_strcmp()\fR function can be called from user or interrupt context.
243 .SH EXAMPLES
245 \fBExample 1 \fRPerform simple default string comparison.
247 .in +2
249 #include <sys/sunddi.h>
252 docmp_default(const char *u1, const char *u2) {
253     int result;
254     int ;
256     result = u8_strcmp(u1, u2, 0, 0, U8_UNICODE_LATEST, &errno);
257     if (errno == EILSEQ)
258         return (-1);
259     if (errno == EINVAL)
260         return (-2);
261     if (errno == EBADF)
262         return (-3);
263     if (errno == ERANGE)
264         return (-4);
266 .in -2
269 \fBExample 2 \fRPerform upper case based case-insensitive comparison with
270 Unicode 3.2.0 date.
272 .in +2
274 #include <sys/sunddi.h>
277 docmp_caseinsensitive_u320(const char *u1, const char *u2) {
278     int result;
279     int errno;
281     result = u8_strcmp(u1, u2, 0, U8_STRCMP_CI_UPPER,
282         U8_UNICODE_320, &errno);
283     if (errno == EILSEQ)
284         return (-1);
285     if (errno == EINVAL)
286         return (-2);
287     if (errno == EBADF)
288         return (-3);
289     if (errno == ERANGE)
290         return (-4);
292     return (result);
295 .in -2
298 \fBExample 3 \fRPerform Unicode Normalization Form D.
301 Perform Unicode Normalization Form D and uppercase-based case-insensitive
302 comparison with Unicode 3.2.0 date.
305 .in +2
307 #include <sys/sunddi.h>
310 docmp_nfd_caseinsensitive_u320(const char *u1, const char *u2) {
311     int result;
312     int errno;
314     result = u8_strcmp(u1, u2, 0,
315         (U8_STRCMP_NFD|U8_STRCMP_CI_UPPER), U8_UNICODE_320,
316         &errno);
317     if (errno == EILSEQ)
318         return (-1);
319     if (errno == EINVAL)
320         return (-2);
321     if (errno == EBADF)
322         return (-3);
323     if (errno == ERANGE)
324         return (-4);
326     return (result);
329 .in -2
331 .SH ATTRIBUTES
334 See \fBattributes\fR(5) for descriptions of the following attributes:
339 box;
340 c | c
341 l | l .
342 ATTRIBUTE TYPE  ATTRIBUTE VALUE
344 Interface Stability     Committed
347 .SH SEE ALSO
350 \fBu8_validate\fR(3C), \fBu8_textprep_str\fR(3C), \fBu8_validate\fR(3C),
351 \fBattributes\fR(5), \fBu8_textprep_str\fR(9F), \fBu8_validate\fR(9F),
352 \fBuconv_u16tou32\fR(9F)
355 The Unicode Standard (http://www.unicode.org)