1MBSRTOWCS(3P) POSIX Programmer's Manual MBSRTOWCS(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 mbsnrtowcs, mbsrtowcs — convert a character string to a wide-character
14 string (restartable)
15
17 #include <wchar.h>
18
19 size_t mbsnrtowcs(wchar_t *restrict dst, const char **restrict src,
20 size_t nmc, size_t len, mbstate_t *restrict ps);
21 size_t mbsrtowcs(wchar_t *restrict dst, const char **restrict src,
22 size_t len, mbstate_t *restrict ps);
23
25 For mbsrtowcs(): The functionality described on this reference page is
26 aligned with the ISO C standard. Any conflict between the requirements
27 described here and the ISO C standard is unintentional. This volume of
28 POSIX.1‐2008 defers to the ISO C standard.
29
30 The mbsrtowcs() function shall convert a sequence of characters, begin‐
31 ning in the conversion state described by the object pointed to by ps,
32 from the array indirectly pointed to by src into a sequence of corre‐
33 sponding wide characters. If dst is not a null pointer, the converted
34 characters shall be stored into the array pointed to by dst. Conver‐
35 sion continues up to and including a terminating null character, which
36 shall also be stored. Conversion shall stop early in either of the fol‐
37 lowing cases:
38
39 * A sequence of bytes is encountered that does not form a valid char‐
40 acter.
41
42 * len codes have been stored into the array pointed to by dst (and
43 dst is not a null pointer).
44
45 Each conversion shall take place as if by a call to the mbrtowc() func‐
46 tion.
47
48 If dst is not a null pointer, the pointer object pointed to by src
49 shall be assigned either a null pointer (if conversion stopped due to
50 reaching a terminating null character) or the address just past the
51 last character converted (if any). If conversion stopped due to reach‐
52 ing a terminating null character, and if dst is not a null pointer, the
53 resulting state described shall be the initial conversion state.
54
55 If ps is a null pointer, the mbsrtowcs() function shall use its own
56 internal mbstate_t object, which is initialized at program start-up to
57 the initial conversion state. Otherwise, the mbstate_t object pointed
58 to by ps shall be used to completely describe the current conversion
59 state of the associated character sequence.
60
61 The mbsnrtowcs() function shall be equivalent to the mbsrtowcs() func‐
62 tion, except that the conversion of characters pointed to by src is
63 limited to at most nmc bytes (the size of the input buffer).
64
65 The behavior of these functions shall be affected by the LC_CTYPE cate‐
66 gory of the current locale.
67
68 The implementation shall behave as if no function defined in this vol‐
69 ume of POSIX.1‐2008 calls these functions.
70
71 The mbsnrtowcs() and mbsrtowcs() functions need not be thread-safe if
72 called with a NULL ps argument.
73
74 The mbsrtowcs() function shall not change the setting of errno if suc‐
75 cessful.
76
78 If the input conversion encounters a sequence of bytes that do not form
79 a valid character, an encoding error occurs. In this case, these func‐
80 tions shall store the value of the macro [EILSEQ] in errno and shall
81 return (size_t)−1; the conversion state is undefined. Otherwise, these
82 functions shall return the number of characters successfully converted,
83 not including the terminating null (if any).
84
86 These functions shall fail if:
87
88 EILSEQ An invalid character sequence is detected.
89
90 These functions may fail if:
91
92 EINVAL ps points to an object that contains an invalid conversion
93 state.
94
95 The following sections are informative.
96
98 None.
99
101 None.
102
104 None.
105
107 None.
108
110 iconv(), mbrtowc(), mbsinit()
111
112 The Base Definitions volume of POSIX.1‐2008, <wchar.h>
113
115 Portions of this text are reprinted and reproduced in electronic form
116 from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
117 -- Portable Operating System Interface (POSIX), The Open Group Base
118 Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
119 cal and Electronics Engineers, Inc and The Open Group. (This is
120 POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
121 event of any discrepancy between this version and the original IEEE and
122 The Open Group Standard, the original IEEE and The Open Group Standard
123 is the referee document. The original Standard can be obtained online
124 at http://www.unix.org/online.html .
125
126 Any typographical or formatting errors that appear in this page are
127 most likely to have been introduced during the conversion of the source
128 files to man page format. To report such errors, see https://www.ker‐
129 nel.org/doc/man-pages/reporting_bugs.html .
130
131
132
133IEEE/The Open Group 2013 MBSRTOWCS(3P)