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"
8 u8_strcmp \- UTF-8 string comparison function
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);
21 Solaris DDI specific (Solaris DDI)
26 \fB\fIs1\fR, \fIs2\fR\fR
29 Pointers to null-terminated UTF-8 strings
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
49 The possible comparison options constructed by a bit-wise-inclusive-OR of the
54 \fB\fBU8_STRCMP_CS\fR\fR
58 Perform case-sensitive string comparison. This is the default.
64 \fB\fBU8_STRCMP_CI_UPPER\fR\fR
68 Perform case-insensitive string comparison based on Unicode upper case
69 converted results of \fIs1\fR and \fIs2\fR.
75 \fB\fBU8_STRCMP_CI_LOWER\fR\fR
79 Perform case-insensitive string comparison based on Unicode lower case
80 converted results of \fIs1\fR and \fIs2\fR.
86 \fB\fBU8_STRCMP_NFD\fR\fR
90 Perform string comparison after \fIs1\fR and \fIs2\fR have been normalized by
91 using Unicode Normalization Form D.
97 \fB\fBU8_STRCMP_NFC\fR\fR
101 Perform string comparison after \fIs1\fR and \fIs2\fR have been normalized by
102 using Unicode Normalization Form C.
108 \fB\fBU8_STRCMP_NFKD\fR\fR
112 Perform string comparison after \fIs1\fR and \fIs2\fR have been normalized by
113 using Unicode Normalization Form KD.
119 \fB\fBU8_STRCMP_NFKC\fR\fR
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.
134 \fB\fIunicode_version\fR\fR
137 The version of Unicode data that should be used during comparison. The
138 following values are supported:
142 \fB\fBU8_UNICODE_320\fR\fR
146 Use Unicode 3.2.0 data during comparison.
152 \fB\fBU8_UNICODE_500\fR\fR
156 Use Unicode 5.0.0 data during comparison.
162 \fB\fBU8_UNICODE_LATEST\fR\fR
166 Use the latest Unicode version data available, which is Unicode 5.0.0.
177 A non-zero value indicates that an error has occurred during comparison. The
178 following values are supported:
185 The specified option values are conflicting and cannot be supported.
194 There was an illegal character at \fIs1\fR, \fIs2\fR, or both.
203 There was an incomplete character at \fIs1\fR, \fIs2\fR, or both.
212 The specified Unicode version value is not supported.
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.
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.
242 The \fBu8_strcmp()\fR function can be called from user or interrupt context.
245 \fBExample 1 \fRPerform simple default string comparison.
249 #include <sys/sunddi.h>
252 docmp_default(const char *u1, const char *u2) {
256 result = u8_strcmp(u1, u2, 0, 0, U8_UNICODE_LATEST, &errno);
269 \fBExample 2 \fRPerform upper case based case-insensitive comparison with
274 #include <sys/sunddi.h>
277 docmp_caseinsensitive_u320(const char *u1, const char *u2) {
281 result = u8_strcmp(u1, u2, 0, U8_STRCMP_CI_UPPER,
282 U8_UNICODE_320, &errno);
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.
307 #include <sys/sunddi.h>
310 docmp_nfd_caseinsensitive_u320(const char *u1, const char *u2) {
314 result = u8_strcmp(u1, u2, 0,
315 (U8_STRCMP_NFD|U8_STRCMP_CI_UPPER), U8_UNICODE_320,
334 See \fBattributes\fR(5) for descriptions of the following attributes:
342 ATTRIBUTE TYPE ATTRIBUTE VALUE
344 Interface Stability Committed
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)