9103 opengroup acknowledgement should be properly formatted in man pages
[unleashed.git] / usr / src / man / man3c / wcstring.3c
blob4df94dcebd38be2e6381322b1be9a46282a54459
1 .\"
2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
6 .\"
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
9 .\" documentation.
10 .\"
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
13 .\"
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group.  In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document.  The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
24 .\"
25 .\" This notice shall appear on any product containing this material.
26 .\"
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
30 .\"
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
35 .\"
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
41 .\"
42 .\"
43 .\" Copyright (c) 1992, X/Open Company Limited.  All Rights Reserved.
44 .\" Portions Copyright (c) 2002, Sun Microsystems, Inc.  All Rights Reserved
45 .\" Copyright 2014 Garrett D'Amore <garrett@damore.org>
46 .\"
47 .TH WCSTRING 3C "Aug 15, 2014"
48 .SH NAME
49 wcstring, wcscat, wscat, wcsncat, wsncat, wcscmp, wscmp, wcsncmp, wsncmp,
50 wcscpy, wscpy, wcsncpy, wsncpy, wslen, wcschr, wschr, wcsrchr, wsrchr,
51 windex, wrindex, wcspbrk, wspbrk, wcswcs, wcsspn, wsspn, wcscspn, wscspn,
52 wcstok, wstok \- wide-character string operations
53 .SH SYNOPSIS
54 .LP
55 .nf
56 #include <wchar.h>
58 \fBwchar_t *\fR\fBwcscat\fR(\fBwchar_t *\fR\fIws1\fR, \fBconst wchar_t *\fR\fIws2\fR);
59 .fi
61 .LP
62 .nf
63 \fBwchar_t *\fR\fBwcsncat\fR(\fBwchar_t *restrict\fR \fIws1\fR, \fBconst wchar_t *restrict\fR \fIws2\fR,
64      \fBsize_t\fR \fIn\fR);
65 .fi
67 .LP
68 .nf
69 \fBint\fR \fBwcscmp\fR(\fBconst wchar_t *\fR\fIws1\fR, \fBconst wchar_t *\fR\fIws2\fR);
70 .fi
72 .LP
73 .nf
74 \fBint\fR \fBwcsncmp\fR(\fBconst wchar_t *\fR\fIws1\fR, \fBconst wchar_t *\fR\fIws2\fR, \fBsize_t\fR \fIn\fR);
75 .fi
77 .LP
78 .nf
79 \fBwchar_t *\fR\fBwcscpy\fR(\fBwchar_t *\fR\fIws1\fR, \fBconst wchar_t *\fR\fIws2\fR);
80 .fi
82 .LP
83 .nf
84 \fBwchar_t *\fR\fBwcsncpy\fR(\fBwchar_t *restrict\fR \fIws1\fR, \fBconst wchar_t *restrict\fR \fIws2\fR,
85      \fBsize_t\fR \fIn\fR);
86 .fi
88 .LP
89 .nf
90 \fBwchar_t *\fR\fBwcschr\fR(\fBconst wchar_t *\fR\fIws\fR, \fBwchar_t\fR \fIwc\fR);
91 .fi
93 .LP
94 .nf
95 \fBwchar_t *\fR\fBwcsrchr\fR(\fBconst wchar_t *\fR\fIws\fR, \fBwchar_t\fR \fIwc\fR);
96 .fi
98 .LP
99 .nf
100 \fBwchar_t *\fR\fBwcspbrk\fR(\fBconst wchar_t *\fR\fIws1\fR, \fBconst wchar_t *\fR\fIws2\fR);
105 \fBwchar_t *\fR\fBwcswcs\fR(\fBconst wchar_t *\fR\fIws1\fR, \fBconst wchar_t *\fR\fIws2\fR);
110 \fBsize_t\fR \fBwcsspn\fR(\fBconst wchar_t *\fR\fIws1\fR, \fBconst wchar_t *\fR\fIws2\fR);
115 \fBsize_t\fR \fBwcscspn\fR(\fBconst wchar_t *\fR\fIws1\fR, \fBconst wchar_t *\fR\fIws2\fR);
118 .SS "XPG4, SUS, SUSv2, SUSv3"
121 \fBwchar_t *\fR\fBwcstok\fR(\fBwchar_t *restrict\fR \fIws1\fR, \fBconst wchar_t *restrict\fR \fIws2\fR);
124 .SS "Default and other standards"
127 \fBwchar_t *\fR\fBwcstok\fR(\fBwchar_t *\fR\fIws1\fR, \fBconst wchar_t *\fR\fIws2\fR, \fBwchar_t **\fR\fIptr\fR);
132 #include <widec.h>
134 \fBwchar_t *\fR\fBwscat\fR(\fBwchar_t *\fR\fIws1\fR, \fBconst wchar_t *\fR\fIws2\fR);
139 \fBwchar_t *\fR\fBwsncat\fR(\fBwchar_t *\fR\fIws1\fR, \fBconst wchar_t *\fR\fIws2\fR, \fBsize_t\fR \fIn\fR);
144 \fBint\fR \fBwscmp\fR(\fBconst wchar_t *\fR\fIws1\fR, \fBconst wchar_t *\fR\fIws2\fR);
149 \fBint\fR \fBwsncmp\fR(\fBconst wchar_t *\fR\fIws1\fR, \fBconst wchar_t *\fR\fIws2\fR, \fBsize_t\fR \fIn\fR);
154 \fBwchar_t *\fR\fBwscpy\fR(\fBwchar_t *\fR\fIws1\fR, \fBconst wchar_t *\fR\fIws2\fR);
159 \fBwchar_t *\fR\fBwsncpy\fR(\fBwchar_t *\fR\fIws1\fR, \fBconst wchar_t *\fR\fIws2\fR, \fBsize_t\fR \fIn\fR);
164 \fBsize_t\fR \fBwslen\fR(\fBconst wchar_t *\fR\fIws\fR);
169 \fBwchar_t *\fR\fBwschr\fR(\fBconst wchar_t *\fR\fIws\fR, \fBwchat_t\fR \fIwc\fR);
174 \fBwchar_t *\fR\fBwsrchr\fR(\fBconst wchar_t *\fR\fIws\fR, \fBwchat_t\fR \fIwc\fR);
179 \fBwchar_t *\fR\fBwspbrk\fR(\fBconst wchar_t *\fR\fIws1\fR, \fBconst wchar_t *\fR\fIws2\fR);
184 \fBsize_t\fR \fBwsspn\fR(\fBconst wchar_t *\fR\fIws1\fR, \fBconst wchar_t *\fR\fIws2\fR);
189 \fBsize_t\fR \fBwscspn\fR(\fBconst wchar_t *\fR\fIws1\fR, \fBconst wchar_t *\fR\fIws2\fR);
194 \fBwchar_t *\fR\fBwstok\fR(\fBwchar_t *\fR\fIws1\fR, \fBconst wchar_t *\fR\fIws2\fR);
199 \fBwchar_t *\fR\fBwindex\fR(\fBconst wchar_t *\fR\fIws\fR, \fBwchar_t\fR \fIwc\fR);
204 \fBwchar_t *\fR\fBwrindex\fR(\fBconst wchar_t *\fR\fIws\fR, \fBwchar_t\fR \fIwc\fR);
207 .SS "ISO C++"
210 #include <wchar.h>
212 \fBconst wchar_t *\fR\fBwcschr\fR(\fBconst wchar_t *\fR\fIws\fR, \fBwchar_t\fR \fIwc\fR);
217 \fBconst wchar_t *\fR\fBwcspbrk\fR(\fBconst wchar_t *\fR\fIws1\fR, \fBconst wchar_t *\fR\fIws2\fR);
222 \fBconst wchar_t *\fR\fBwcsrchr\fR(\fBconst wchar_t *\fR\fIws\fR, \fBwchar_t\fR \fIwc\fR);
227 #include <cwchar>
229 \fBwchar_t *std::\fR\fBwcschr\fR(\fBwchar_t *\fR\fIws\fR, \fBwchar_t\fR \fIwc\fR);
234 \fBwchar_t *std::\fR\fBwcspbrk\fR(\fBwchar_t *\fR\fIws1\fR, \fBconst wchar_t *\fR\fIws2\fR);
239 \fBwchar_t *std::\fR\fBwcsrchr\fR(\fBwchar_t *\fR\fIws\fR, \fBwchar_t\fR \fIwc\fR);
242 .SH DESCRIPTION
244 These functions operate on wide-character strings terminated by \fBwchar_t\fR
245 \fINULL\fR characters. During appending or copying, these routines do not check
246 for an overflow condition of the receiving string. In the following, \fIws\fR,
247 \fIws1\fR, and \fIws2\fR point to wide-character strings terminated by a
248 \fBwchar_t NULL\fR.
249 .SS "wcscat(\|), wscat(\|)"
251 The \fBwcscat()\fR and \fBwscat()\fR functions append a copy of the
252 wide-character string pointed to by \fIws2\fR (including the terminating null
253 wide-character code) to the end of the wide-character string pointed to by
254 \fIws1\fR. The initial wide-character code of \fIws2\fR overwrites the null
255 wide-character code at the end of \fIws1\fR. If copying takes place between
256 objects that overlap, the behavior is undefined. Both functions return
257 \fIs1\fR; no return value is reserved to indicate an error.
258 .SS "wcsncat(\|), wsncat(\|)"
260 The \fBwcsncat()\fR and \fBwsncat()\fR functions append not more than \fIn\fR
261 wide-character codes (a null wide-character code and wide-character codes that
262 follow it are not appended) from the array pointed to by \fIws2\fR to the end
263 of the wide-character string pointed to by \fIws1\fR. The initial
264 wide-character code of \fIws2\fR overwrites the null wide-character code at the
265 end of \fIws1\fR. A terminating null wide-character code is always appended to
266 the result. Both functions return \fIws1\fR; no return value is reserved to
267 indicate an error.
268 .SS "wcscmp(\|), wscmp(\|)"
270 The \fBwcscmp()\fR and \fBwscmp()\fR functions compare the wide-character
271 string pointed to by \fIws1\fR to the wide-character string pointed to by
272 \fIws2\fR. The sign of a non-zero return value is determined by the sign of the
273 difference between the values of the first pair of wide-character codes that
274 differ in the objects being compared. Upon completion, both functions return an
275 integer greater than, equal to, or less than zero, if the wide-character string
276 pointed to by \fIws1\fR is greater than, equal to, or less than the
277 wide-character string pointed to by \fIws2\fR.
278 .SS "wcsncmp(\|), wsncmp(\|)"
280 The \fBwcsncmp()\fR and \fBwsncmp()\fR functions compare not more than \fIn\fR
281 wide-character codes (wide-character codes that follow a null wide character
282 code are not compared) from the array pointed to by \fIws1\fR to the array
283 pointed to by \fIws2\fR. The sign of a non-zero return value is determined by
284 the sign of the difference between the values of the first pair of
285 wide-character codes that differ in the objects being compared. Upon successful
286 completion, both functions return an integer greater than, equal to, or less
287 than zero, if the possibly null-terminated array pointed to by \fIws1\fR is
288 greater than, equal to, or less than the possibly null-terminated array pointed
289 to by \fIws2\fR.
290 .SS "wcscpy(\|), wscpy(\|)"
292 The \fBwcscpy()\fR and \fBwscpy()\fR functions copy the wide-character string
293 pointed to by \fIws2\fR (including the terminating null wide-character code)
294 into the array pointed to by \fIws1\fR. If copying takes place between objects
295 that overlap, the behavior is undefined. Both functions return \fIws1\fR; no
296 return value is reserved to indicate an error.
297 .SS "wcsncpy(\|), wsncpy(\|)"
299 The \fBwcsncpy()\fR and \fBwsncpy()\fR functions  copy not more than \fIn\fR
300 wide-character codes (wide-character codes that follow a null wide character
301 code are not copied) from the array pointed to by \fIws2\fR to the array
302 pointed to by \fIws1\fR. If copying takes place between objects that overlap,
303 the behavior is undefined. If the array pointed to by \fIws2\fR is a
304 wide-character string that is shorter than \fIn\fR wide-character codes, null
305 wide-character codes are appended to the copy in the array pointed to by
306 \fIws1\fR, until a total \fIn\fR wide-character codes are written. Both
307 functions return \fI ws1\fR; no return value is reserved to indicate an error.
308 .SS "wslen(\|)"
310 The \fBwslen()\fR function computes the number of
311 wide-character codes in the wide-character string to which \fIws\fR points, not
312 including the terminating null wide-character code. It returns
313 \fIws\fR; no return value is reserved to indicate an error.
314 .SS "wcschr(\|), wschr(\|)"
316 The \fBwcschr()\fR and \fBwschr()\fR functions locate the first occurrence of
317 \fIwc\fR in the wide-character string pointed to by \fIws\fR. The value of
318 \fIwc\fR must be a character representable as a type \fBwchar_t\fR and must be
319 a wide-character code corresponding to a valid character in the current locale.
320 The terminating null wide-character code is considered to be part of the
321 wide-character string. Upon completion, both functions return a pointer to the
322 wide-character code, or a null pointer if the wide-character code is not found.
323 .SS "wcsrchr(\|), wsrchr(\|)"
325 The \fBwcsrchr()\fR and \fBwsrchr()\fR functions locate the last occurrence of
326 \fIwc\fR in the wide-character string pointed to by \fIws\fR. The value of
327 \fIwc\fR must be a character representable as a type \fBwchar_t\fR and must be
328 a wide-character code corresponding to a valid character in the current locale.
329 The terminating null wide-character code is considered to be part of the
330 wide-character string. Upon successful completion, both functions return a
331 pointer to the wide-character code, or a null pointer if \fIwc\fR does not
332 occur in the wide-character string.
333 .SS "windex(\|), wrindex(\|)"
335 The \fBwindex()\fR and \fBwrindex()\fR functions behave the same as
336 \fBwschr()\fR and \fBwsrchr()\fR, respectively.
337 .SS "wcspbrk(\|), wspbrk(\|)"
339 The \fBwcspbrk()\fR and \fBwspbrk()\fR functions locate the first occurrence in
340 the wide character string pointed to by \fIws1\fR of any wide-character code
341 from the wide-character string pointed to by \fIws2\fR. Upon successful
342 completion, the function returns a pointer to the wide-character code, or a
343 null pointer if no wide-character code from \fIws2\fR occurs in \fIws1\fR.
344 .SS "wcswcs(\|)"
346 The \fBwcswcs()\fR function locates the first occurrence in the wide-character
347 string pointed to by \fIws1\fR of the sequence of wide-character codes
348 (excluding the terminating null wide-character code) in the wide-character
349 string pointed to by \fIws2\fR. Upon successful completion, the function
350 returns a pointer to the located wide-character string, or a null pointer if
351 the wide-character string is not found. If \fIws2\fR points to a wide-character
352 string with zero length, the function returns \fIws1\fR.
353 .SS "wcsspn(\|), wsspn(\|)"
355 The \fBwcsspn()\fR and \fBwsspn()\fR functions compute the length of the
356 maximum initial segment of the wide-character string pointed to by \fIws1\fR
357 which consists entirely of wide-character codes from the wide-character string
358 pointed to by \fIws2\fR. Both functions return the length \fIws1\fR; no return
359 value is reserved to indicate an error.
360 .SS "wcscspn(\|), wscspn(\|)"
362 The \fBwcscspn()\fR and \fBwscspn()\fR functions compute the length of the
363 maximum initial segment of the wide-character string pointed to by \fIws1\fR
364 which consists entirely of wide-character codes \fInot\fR from the
365 wide-character string pointed to by \fIws2\fR. Both functions return the length
366 of the initial substring of \fIws1\fR; no return value is reserved to indicate
367 an error.
368 .SS "wcstok(\|), wstok(\|)"
370 A sequence of calls to the \fBwcstok()\fR and \fBwstok()\fR functions break the
371 wide-character string pointed to by \fIws1\fR into a sequence of tokens, each
372 of which is delimited by a wide-character code from the wide-character string
373 pointed to by \fIws2\fR.
374 .SS "Default and other standards"
376 The third argument points to a caller-provided \fBwchar_t\fR pointer into which
377 the \fBwcstok()\fR function stores information necessary for it to continue
378 scanning the same wide-character string. This argument is not available with
379 the XPG4 and SUS versions of \fBwcstok()\fR, nor is it available with the
380 \fBwstok()\fR function.  See \fBstandards\fR(5).
382 The first call in the sequence has \fIws1\fR as its first argument, and is
383 followed by calls with a null pointer as their first argument. The separator
384 string pointed to by \fIws2\fR may be different from call to call.
386 The first call in the sequence searches the wide-character string pointed to by
387 \fIws1\fR for the first wide-character code that is \fInot\fR contained in the
388 current separator string pointed to by \fIws2\fR. If no such wide-character
389 code is found, then there are no tokens in the wide-character string pointed to
390 by \fIws1\fR, and \fBwcstok()\fR and \fBwstok()\fR return a null pointer. If
391 such a wide-character code is found, it is the start of the first token.
393 The \fBwcstok()\fR and \fBwstok()\fR functions then search from that point for
394 a wide-character code that \fIis\fR contained in the current separator string.
395 If no such wide-character code is found, the current token extends to the end
396 of the wide-character string pointed to by \fIws1\fR, and subsequent searches
397 for a token will return a null pointer. If such a wide-character code is found,
398 it is overwritten by a null wide character, which terminates the current token.
399 The \fBwcstok()\fR and \fBwstok()\fR functions save a pointer to the following
400 wide-character code, from which the next search for a token will start.
402 Each subsequent call, with a null pointer as the value of the first argument,
403 starts searching from the saved pointer and behaves as described above.
405 Upon successful completion, both functions return a pointer to the first
406 wide-character code of a token. Otherwise, if there is no token, a null pointer
407 is returned.
408 .SH ATTRIBUTES
410 See \fBattributes\fR(5) for descriptions of the following attributes:
415 box;
416 c | c
417 l | l .
418 ATTRIBUTE TYPE  ATTRIBUTE VALUE
420 CSI     Enabled
422 Interface Stability     See NOTES.
424 MT-Level        MT-Safe
427 .SH SEE ALSO
429 \fBmalloc\fR(3C),
430 \fBstring\fR(3C),
431 \fBwcscasecmp\fR(3C),
432 \fBwcsdup\fR(3C),
433 \fBwcslen\fR(3C),
434 \fBwcswidth\fR(3C),
435 \fBwcwidth\fR(3C),
436 \fBattributes\fR(5),
437 \fBstandards\fR(5)
438 .SH NOTES
440 The \fBwcscat()\fR, \fBwcsncat()\fR, \fBwcscmp()\fR, \fBwcsncmp()\fR,
441 \fBwcscpy()\fR, \fBwcsncpy()\fR, \fBwcschr()\fR,
442 \fBwcsrchr()\fR, \fBwcspbrk()\fR, \fBwcswcs()\fR, \fBwcsspn()\fR,
443 \fBwcscspn()\fR, and \fBwcstok()\fR functions are Standard. The \fBwscat()\fR,
444 \fBwsncat()\fR, \fBwscmp()\fR, \fBwsncmp()\fR, \fBwscpy()\fR, \fBwsncpy()\fR,
445 \fBwslen()\fR, \fBwschr()\fR, \fBwsrchr()\fR, \fBwspbrk()\fR, \fBwsspn()\fR,
446 \fBwstok()\fR, \fBwindex()\fR, and \fBwrindex()\fR functions are Stable.