1MBSTOWCS(3P)               POSIX Programmer's Manual              MBSTOWCS(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       mbstowcs - convert a character string to a wide-character string
13

SYNOPSIS

15       #include <stdlib.h>
16
17       size_t mbstowcs(wchar_t *restrict pwcs, const char *restrict s,
18              size_t n);
19
20

DESCRIPTION

22       The mbstowcs() function shall convert a  sequence  of  characters  that
23       begins in the initial shift state from the array pointed to by s into a
24       sequence of corresponding wide-character codes and shall store not more
25       than n wide-character codes into the array pointed to by pwcs. No char‐
26       acters that follow a null byte (which is converted into a  wide-charac‐
27       ter  code  with value 0) shall be examined or converted. Each character
28       shall be converted as if by a call to mbtowc(), except that  the  shift
29       state of mbtowc() is not affected.
30
31       No  more  than  n elements shall be modified in the array pointed to by
32       pwcs. If copying takes place between objects that overlap, the behavior
33       is undefined.
34
35       The  behavior  of this function shall be affected by the LC_CTYPE cate‐
36       gory of the current locale.  If pwcs  is  a  null  pointer,  mbstowcs()
37       shall return the length required to convert the entire array regardless
38       of the value of n, but no values are stored.
39

RETURN VALUE

41       If  an  invalid  character  is  encountered,  mbstowcs()  shall  return
42       (size_t)-1  and may set errno to indicate the error.
43
44       Otherwise,  mbstowcs()  shall  return  the number of the array elements
45       modified  (or required if pwcs is null),  not including a terminating 0
46       code,  if  any.  The  array  shall  not be zero-terminated if the value
47       returned is n.
48

ERRORS

50       The mbstowcs() function may fail if:
51
52       EILSEQ Invalid byte sequence is detected.
53
54
55       The following sections are informative.
56

EXAMPLES

58       None.
59

APPLICATION USAGE

61       None.
62

RATIONALE

64       None.
65

FUTURE DIRECTIONS

67       None.
68

SEE ALSO

70       mblen(), mbtowc(), wctomb(), wcstombs(), the Base Definitions volume of
71       IEEE Std 1003.1-2001, <stdlib.h>
72
74       Portions  of  this text are reprinted and reproduced in electronic form
75       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
76       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
77       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
78       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
79       event of any discrepancy between this version and the original IEEE and
80       The  Open Group Standard, the original IEEE and The Open Group Standard
81       is the referee document. The original Standard can be  obtained  online
82       at http://www.opengroup.org/unix/online.html .
83
84
85
86IEEE/The Open Group                  2003                         MBSTOWCS(3P)
Impressum