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       mbsrtowcs - convert a  character  string  to  a  wide-character  string
13       (restartable)
14

SYNOPSIS

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

DESCRIPTION

23       The mbsrtowcs() function shall convert a sequence of characters, begin‐
24       ning in the conversion state described by the object pointed to by  ps,
25       from  the  array indirectly pointed to by src into a sequence of corre‐
26       sponding wide characters. If dst is not a null pointer,  the  converted
27       characters  shall  be stored into the array pointed to by dst.  Conver‐
28       sion continues up to and including a terminating null character,  which
29       shall also be stored. Conversion shall stop early in either of the fol‐
30       lowing cases:
31
32        * A sequence of bytes is encountered that does not form a valid  char‐
33          acter.
34
35        * len codes have been stored into the array pointed to by dst (and dst
36          is not a null pointer).
37
38       Each conversion shall take place as if by a call to the mbrtowc() func‐
39       tion.
40
41       If  dst  is  not  a  null pointer, the pointer object pointed to by src
42       shall be assigned either a null pointer (if conversion stopped  due  to
43       reaching  a  terminating  null  character) or the address just past the
44       last character converted (if any). If conversion stopped due to  reach‐
45       ing a terminating null character, and if dst is not a null pointer, the
46       resulting state described shall be the initial conversion state.
47
48       If ps is a null pointer, the mbsrtowcs() function  shall  use  its  own
49       internal  mbstate_t object, which is initialized at program start-up to
50       the initial conversion state. Otherwise, the mbstate_t  object  pointed
51       to  by  ps  shall be used to completely describe the current conversion
52       state of the associated character sequence. The implementation  behaves
53       as  if no function defined in this volume of IEEE Std 1003.1-2001 calls
54       mbsrtowcs().
55
56       The behavior of this function shall be affected by the  LC_CTYPE  cate‐
57       gory of the current locale.
58

RETURN VALUE

60       If the input conversion encounters a sequence of bytes that do not form
61       a valid character, an encoding error occurs. In this  case,  the  mbsr‐
62       towcs()  function  stores  the value of the macro [EILSEQ] in errno and
63       shall return (size_t)-1; the conversion state is undefined.  Otherwise,
64       it  shall  return  the number of characters successfully converted, not
65       including the terminating null (if any).
66

ERRORS

68       The mbsrtowcs() function may fail if:
69
70       EINVAL ps points to an  object  that  contains  an  invalid  conversion
71              state.
72
73       EILSEQ Invalid character sequence is detected.
74
75
76       The following sections are informative.
77

EXAMPLES

79       None.
80

APPLICATION USAGE

82       None.
83

RATIONALE

85       None.
86

FUTURE DIRECTIONS

88       None.
89

SEE ALSO

91       mbsinit(),     mbrtowc(),    the    Base    Definitions    volume    of
92       IEEE Std 1003.1-2001, <wchar.h>
93
95       Portions of this text are reprinted and reproduced in  electronic  form
96       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
97       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
98       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
99       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
100       event of any discrepancy between this version and the original IEEE and
101       The Open Group Standard, the original IEEE and The Open Group  Standard
102       is  the  referee document. The original Standard can be obtained online
103       at http://www.opengroup.org/unix/online.html .
104
105
106
107IEEE/The Open Group                  2003                        MBSRTOWCS(3P)
Impressum