1MBSRTOWCS(3P)              POSIX Programmer's Manual             MBSRTOWCS(3P)
2
3
4

PROLOG

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

NAME

12       mbsnrtowcs, mbsrtowcs — convert a character string to a  wide-character
13       string (restartable)
14

SYNOPSIS

16       #include <wchar.h>
17
18       size_t mbsnrtowcs(wchar_t *restrict dst, const char **restrict src,
19           size_t nmc, size_t len, mbstate_t *restrict ps);
20       size_t mbsrtowcs(wchar_t *restrict dst, const char **restrict src,
21           size_t len, mbstate_t *restrict ps);
22

DESCRIPTION

24       For  mbsrtowcs(): The functionality described on this reference page is
25       aligned with the ISO C standard. Any conflict between the  requirements
26       described  here and the ISO C standard is unintentional. This volume of
27       POSIX.1‐2017 defers to the ISO C standard.
28
29       The mbsrtowcs() function shall convert a sequence of characters, begin‐
30       ning  in the conversion state described by the object pointed to by ps,
31       from the array indirectly pointed to by src into a sequence  of  corre‐
32       sponding  wide  characters. If dst is not a null pointer, the converted
33       characters shall be stored into the array pointed to by  dst.   Conver‐
34       sion  continues up to and including a terminating null character, which
35       shall also be stored. Conversion shall stop early in either of the fol‐
36       lowing cases:
37
38        *  A sequence of bytes is encountered that does not form a valid char‐
39           acter.
40
41        *  len codes have been stored into the array pointed to  by  dst  (and
42           dst is not a null pointer).
43
44       Each conversion shall take place as if by a call to the mbrtowc() func‐
45       tion.
46
47       If dst is not a null pointer, the pointer  object  pointed  to  by  src
48       shall  be  assigned either a null pointer (if conversion stopped due to
49       reaching a terminating null character) or the  address  just  past  the
50       last  character converted (if any). If conversion stopped due to reach‐
51       ing a terminating null character, and if dst is not a null pointer, the
52       resulting state described shall be the initial conversion state.
53
54       If  ps  is  a  null pointer, the mbsrtowcs() function shall use its own
55       internal mbstate_t object, which is initialized at program start-up  to
56       the  initial  conversion state. Otherwise, the mbstate_t object pointed
57       to by ps shall be used to completely describe  the  current  conversion
58       state of the associated character sequence.
59
60       The  mbsnrtowcs() function shall be equivalent to the mbsrtowcs() func‐
61       tion, except that the conversion of characters indirectly pointed to by
62       src is limited to at most nmc bytes (the size of the input buffer), and
63       under conditions where mbsrtowcs() would assign the address  just  past
64       the  last character converted (if any) to the pointer object pointed to
65       by src, mbsnrtowcs() shall instead assign the  address  just  past  the
66       last  byte processed (if any) to that pointer object. If the input buf‐
67       fer ends with an incomplete character, it is unspecified  whether  con‐
68       version  stops at the end of the previous character (if any), or at the
69       end of the input buffer. In the  latter  case,  a  subsequent  call  to
70       mbsnrtowcs() with an input buffer that starts with the remainder of the
71       incomplete character shall correctly complete the  conversion  of  that
72       character.
73
74       The behavior of these functions shall be affected by the LC_CTYPE cate‐
75       gory of the current locale.
76
77       The implementation shall behave as if no function defined in this  vol‐
78       ume of POSIX.1‐2017 calls these functions.
79
80       The  mbsnrtowcs()  and mbsrtowcs() functions need not be thread-safe if
81       called with a NULL ps argument.
82
83       The mbsrtowcs() function shall not change the setting of errno if  suc‐
84       cessful.
85

RETURN VALUE

87       If the input conversion encounters a sequence of bytes that do not form
88       a valid character, an encoding error occurs. In this case, these  func‐
89       tions  shall  store  the value of the macro [EILSEQ] in errno and shall
90       return (size_t)-1; the conversion state is undefined.  Otherwise, these
91       functions shall return the number of characters successfully converted,
92       not including the terminating null (if any).
93

ERRORS

95       These functions shall fail if:
96
97       EILSEQ An invalid character sequence is detected.  In the POSIX  locale
98              an  [EILSEQ]  error cannot occur since all byte values are valid
99              characters.
100
101       These functions may fail if:
102
103       EINVAL ps points to an  object  that  contains  an  invalid  conversion
104              state.
105
106       The following sections are informative.
107

EXAMPLES

109       None.
110

APPLICATION USAGE

112       None.
113

RATIONALE

115       None.
116

FUTURE DIRECTIONS

118       A  future  version  may require that when the input buffer ends with an
119       incomplete character, conversion stops at the end of the input buffer.
120

SEE ALSO

122       iconv(), mbrtowc(), mbsinit()
123
124       The Base Definitions volume of POSIX.1‐2017, <wchar.h>
125
127       Portions of this text are reprinted and reproduced in  electronic  form
128       from  IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
129       table Operating System Interface (POSIX), The Open Group Base  Specifi‐
130       cations  Issue  7, 2018 Edition, Copyright (C) 2018 by the Institute of
131       Electrical and Electronics Engineers, Inc and The Open Group.   In  the
132       event of any discrepancy between this version and the original IEEE and
133       The Open Group Standard, the original IEEE and The Open Group  Standard
134       is  the  referee document. The original Standard can be obtained online
135       at http://www.opengroup.org/unix/online.html .
136
137       Any typographical or formatting errors that appear  in  this  page  are
138       most likely to have been introduced during the conversion of the source
139       files to man page format. To report such errors,  see  https://www.ker
140       nel.org/doc/man-pages/reporting_bugs.html .
141
142
143
144IEEE/The Open Group                  2017                        MBSRTOWCS(3P)
Impressum