1MBSRTOWCS(P) POSIX Programmer's Manual MBSRTOWCS(P)
2
3
4
6 mbsrtowcs - convert a character string to a wide-character string
7 (restartable)
8
10 #include <wchar.h>
11
12 size_t mbsrtowcs(wchar_t *restrict dst, const char **restrict src,
13 size_t len, mbstate_t *restrict ps);
14
15
17 The mbsrtowcs() function shall convert a sequence of characters, begin‐
18 ning in the conversion state described by the object pointed to by ps,
19 from the array indirectly pointed to by src into a sequence of corre‐
20 sponding wide characters. If dst is not a null pointer, the converted
21 characters shall be stored into the array pointed to by dst. Conver‐
22 sion continues up to and including a terminating null character, which
23 shall also be stored. Conversion shall stop early in either of the fol‐
24 lowing cases:
25
26 * A sequence of bytes is encountered that does not form a valid char‐
27 acter.
28
29 * len codes have been stored into the array pointed to by dst (and dst
30 is not a null pointer).
31
32 Each conversion shall take place as if by a call to the mbrtowc() 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 character) or the address just past the
38 last character converted (if any). If conversion stopped due to reach‐
39 ing a terminating null character, and if dst is not a null pointer, the
40 resulting state described shall be the initial conversion state.
41
42 If ps is a null pointer, the mbsrtowcs() 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 behaves
47 as if no function defined in this volume of IEEE Std 1003.1-2001 calls
48 mbsrtowcs().
49
50 The behavior of this function shall be affected by the LC_CTYPE cate‐
51 gory of the current locale.
52
54 If the input conversion encounters a sequence of bytes that do not form
55 a valid character, an encoding error occurs. In this case, the mbsr‐
56 towcs() function stores the value of the macro [EILSEQ] in errno and
57 shall return (size_t)-1; the conversion state is undefined. Otherwise,
58 it shall return the number of characters successfully converted, not
59 including the terminating null (if any).
60
62 The mbsrtowcs() function may fail if:
63
64 EINVAL ps points to an object that contains an invalid conversion
65 state.
66
67 EILSEQ Invalid character sequence is detected.
68
69
70 The following sections are informative.
71
73 None.
74
76 None.
77
79 None.
80
82 None.
83
85 mbsinit() , mbrtowc() , the Base Definitions volume of
86 IEEE Std 1003.1-2001, <wchar.h>
87
89 Portions of this text are reprinted and reproduced in electronic form
90 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
91 -- Portable Operating System Interface (POSIX), The Open Group Base
92 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
93 Electrical and Electronics Engineers, Inc and The Open Group. In the
94 event of any discrepancy between this version and the original IEEE and
95 The Open Group Standard, the original IEEE and The Open Group Standard
96 is the referee document. The original Standard can be obtained online
97 at http://www.opengroup.org/unix/online.html .
98
99
100
101IEEE/The Open Group 2003 MBSRTOWCS(P)