1WCSRTOMBS(P) POSIX Programmer's Manual WCSRTOMBS(P)
2
3
4
6 wcsrtombs - convert a wide-character string to a character string
7 (restartable)
8
10 #include <wchar.h>
11
12 size_t wcsrtombs(char *restrict dst, const wchar_t **restrict src,
13 size_t len, mbstate_t *restrict ps);
14
15
17 The wcsrtombs() function shall convert a sequence of wide characters
18 from the array indirectly pointed to by src into a sequence of corre‐
19 sponding characters, beginning in the conversion state described by the
20 object pointed to by ps. If dst is not a null pointer, the converted
21 characters shall then be stored into the array pointed to by dst. Con‐
22 version continues up to and including a terminating null wide charac‐
23 ter, which shall also be stored. Conversion shall stop earlier in the
24 following cases:
25
26 * When a code is reached that does not correspond to a valid character
27
28 * When the next character would exceed the limit of len total bytes to
29 be stored in the array pointed to by dst (and dst is not a null
30 pointer)
31
32 Each conversion shall take place as if by a call to the wcrtomb() func‐
33 tion.
34
35 If dst is not a null pointer, the pointer object pointed to by src
36 shall be assigned either a null pointer (if conversion stopped due to
37 reaching a terminating null wide character) or the address just past
38 the last wide character converted (if any). If conversion stopped due
39 to reaching a terminating null wide character, the resulting state
40 described shall be the initial conversion state.
41
42 If ps is a null pointer, the wcsrtombs() function shall use its own
43 internal mbstate_t object, which is initialized at program start-up to
44 the initial conversion state. Otherwise, the mbstate_t object pointed
45 to by ps shall be used to completely describe the current conversion
46 state of the associated character sequence. The implementation shall
47 behave as if no function defined in this volume of IEEE Std 1003.1-2001
48 calls wcsrtombs().
49
50 If the application uses any of the _POSIX_THREAD_SAFE_FUNCTIONS or
51 _POSIX_THREADS functions, the application shall ensure that the wcsr‐
52 tombs() function is called with a non-NULL ps argument.
53
54 The behavior of this function shall be affected by the LC_CTYPE cate‐
55 gory of the current locale.
56
58 If conversion stops because a code is reached that does not correspond
59 to a valid character, an encoding error occurs. In this case, the wcsr‐
60 tombs() function shall store the value of the macro [EILSEQ] in errno
61 and return (size_t)-1; the conversion state is undefined. Otherwise, it
62 shall return the number of bytes in the resulting character sequence,
63 not including the terminating null (if any).
64
66 The wcsrtombs() function may fail if:
67
68 EINVAL ps points to an object that contains an invalid conversion
69 state.
70
71 EILSEQ A wide-character code does not correspond to a valid character.
72
73
74 The following sections are informative.
75
77 None.
78
80 None.
81
83 None.
84
86 None.
87
89 mbsinit() , wcrtomb() , the Base Definitions volume of
90 IEEE Std 1003.1-2001, <wchar.h>
91
93 Portions of this text are reprinted and reproduced in electronic form
94 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
95 -- Portable Operating System Interface (POSIX), The Open Group Base
96 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
97 Electrical and Electronics Engineers, Inc and The Open Group. In the
98 event of any discrepancy between this version and the original IEEE and
99 The Open Group Standard, the original IEEE and The Open Group Standard
100 is the referee document. The original Standard can be obtained online
101 at http://www.opengroup.org/unix/online.html .
102
103
104
105IEEE/The Open Group 2003 WCSRTOMBS(P)