3 <<mbsrtowcs>>, <<mbsnrtowcs>>---convert a character string to a wide-character string
16 size_t mbsrtowcs(wchar_t *<[dst]>, const char **<[src]>, size_t <[len]>,
20 size_t _mbsrtowcs_r(struct _reent *<[ptr]>, wchar_t *<[dst]>,
21 const char **<[src]>, size_t <[len]>,
25 size_t mbsnrtowcs(wchar_t *<[dst]>, const char **<[src]>,
26 size_t <[nms]>, size_t <[len]>, mbstate_t *<[ps]>);
29 size_t _mbsnrtowcs_r(struct _reent *<[ptr]>, wchar_t *<[dst]>,
30 const char **<[src]>, size_t <[nms]>,
31 size_t <[len]>, mbstate_t *<[ps]>);
35 size_t mbsrtowcs(<[dst]>, <[src]>, <[len]>, <[ps]>)
42 size_t _mbsrtowcs_r(<[ptr]>, <[dst]>, <[src]>, <[len]>, <[ps]>)
43 struct _reent *<[ptr]>;
50 size_t mbsnrtowcs(<[dst]>, <[src]>, <[nms]>, <[len]>, <[ps]>)
58 size_t _mbsnrtowcs_r(<[ptr]>, <[dst]>, <[src]>, <[nms]>, <[len]>, <[ps]>)
59 struct _reent *<[ptr]>;
67 The <<mbsrtowcs>> function converts a sequence of multibyte characters
68 pointed to indirectly by <[src]> into a sequence of corresponding wide
69 characters and stores at most <[len]> of them in the wchar_t array pointed
70 to by <[dst]>, until it encounters a terminating null character ('\0').
72 If <[dst]> is NULL, no characters are stored.
74 If <[dst]> is not NULL, the pointer pointed to by <[src]> is updated to point
75 to the character after the one that conversion stopped at. If conversion
76 stops because a null character is encountered, *<[src]> is set to NULL.
78 The mbstate_t argument, <[ps]>, is used to keep track of the shift state. If
79 it is NULL, <<mbsrtowcs>> uses an internal, static mbstate_t object, which
80 is initialized to the initial conversion state at program startup.
82 The <<mbsnrtowcs>> function behaves identically to <<mbsrtowcs>>, except that
83 conversion stops after reading at most <[nms]> bytes from the buffer pointed
87 The <<mbsrtowcs>> and <<mbsnrtowcs>> functions return the number of wide
88 characters stored in the array pointed to by <[dst]> if successful, otherwise
89 it returns (size_t)-1.
92 <<mbsrtowcs>> is defined by the C99 standard.
93 <<mbsnrtowcs>> is defined by the POSIX.1-2008 standard.
104 _DEFUN (_mbsnrtowcs_r, (r, dst, src, nms, len, ps),
105 struct _reent *r _AND
107 const char **src _AND
121 _REENT_CHECK_MISC(r);
122 ps = &(_REENT_MBSRTOWCS_STATE(r));
128 /* Ignore original len value and do not alter src pointer if the
129 dst pointer is NULL. */
138 bytes = _mbrtowc_r (r, ptr, *src, nms, ps);
144 ptr = (dst == NULL) ? NULL : ptr + 1;
147 else if (bytes == -2)
170 _DEFUN (mbsnrtowcs, (dst, src, nms, len, ps),
172 const char **src _AND
177 return _mbsnrtowcs_r (_REENT, dst, src, nms, len, ps);
179 #endif /* !_REENT_ONLY */