1WCSTOMBS(3P) POSIX Programmer's Manual WCSTOMBS(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
11
13 wcstombs — convert a wide-character string to a character string
14
16 #include <stdlib.h>
17
18 size_t wcstombs(char *restrict s, const wchar_t *restrict pwcs,
19 size_t n);
20
22 The functionality described on this reference page is aligned with the
23 ISO C standard. Any conflict between the requirements described here
24 and the ISO C standard is unintentional. This volume of POSIX.1‐2008
25 defers to the ISO C standard.
26
27 The wcstombs() function shall convert the sequence of wide-character
28 codes that are in the array pointed to by pwcs into a sequence of char‐
29 acters that begins in the initial shift state and store these charac‐
30 ters into the array pointed to by s, stopping if a character would
31 exceed the limit of n total bytes or if a null byte is stored. Each
32 wide-character code shall be converted as if by a call to wctomb(),
33 except that the shift state of wctomb() shall not be affected.
34
35 The behavior of this function shall be affected by the LC_CTYPE cate‐
36 gory of the current locale.
37
38 No more than n bytes shall be modified in the array pointed to by s.
39 If copying takes place between objects that overlap, the behavior is
40 undefined. If s is a null pointer, wcstombs() shall return the length
41 required to convert the entire array regardless of the value of n, but
42 no values are stored.
43
45 If a wide-character code is encountered that does not correspond to a
46 valid character (of one or more bytes each), wcstombs() shall return
47 (size_t)−1. Otherwise, wcstombs() shall return the number of bytes
48 stored in the character array, not including any terminating null byte.
49 The array shall not be null-terminated if the value returned is n.
50
52 The wcstombs() function shall fail if:
53
54 EILSEQ A wide-character code does not correspond to a valid character.
55
56 The following sections are informative.
57
59 None.
60
62 None.
63
65 None.
66
68 None.
69
71 mblen(), mbtowc(), mbstowcs(), wctomb()
72
73 The Base Definitions volume of POSIX.1‐2008, <stdlib.h>
74
76 Portions of this text are reprinted and reproduced in electronic form
77 from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
78 -- Portable Operating System Interface (POSIX), The Open Group Base
79 Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
80 cal and Electronics Engineers, Inc and The Open Group. (This is
81 POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
82 event of any discrepancy between this version and the original IEEE and
83 The Open Group Standard, the original IEEE and The Open Group Standard
84 is the referee document. The original Standard can be obtained online
85 at http://www.unix.org/online.html .
86
87 Any typographical or formatting errors that appear in this page are
88 most likely to have been introduced during the conversion of the source
89 files to man page format. To report such errors, see https://www.ker‐
90 nel.org/doc/man-pages/reporting_bugs.html .
91
92
93
94IEEE/The Open Group 2013 WCSTOMBS(3P)