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

DESCRIPTION

21       The functionality described on this reference page is aligned with  the
22       ISO C  standard.  Any  conflict between the requirements described here
23       and the ISO C standard is unintentional. This  volume  of  POSIX.1‐2017
24       defers to the ISO C standard.
25
26       The  mbstowcs()  function  shall  convert a sequence of characters that
27       begins in the initial shift state from the array pointed to by s into a
28       sequence of corresponding wide-character codes and shall store not more
29       than n wide-character codes into the array  pointed  to  by  pwcs.   No
30       characters  that  follow  a  null byte (which is converted into a wide-
31       character code with value 0) shall be examined or converted. Each char‐
32       acter  shall  be converted as if by a call to mbtowc(), except that the
33       shift state of mbtowc() is not affected.
34
35       No more than n elements shall be modified in the array  pointed  to  by
36       pwcs.   If copying takes place between objects that overlap, the behav‐
37       ior is undefined.
38
39       The behavior of this function shall be affected by the  LC_CTYPE  cate‐
40       gory  of  the  current  locale.   If pwcs is a null pointer, mbstowcs()
41       shall return the length required to convert the entire array regardless
42       of the value of n, but no values are stored.
43

RETURN VALUE

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

ERRORS

54       The mbstowcs() function shall fail if:
55
56       EILSEQ An  invalid  character sequence is detected. In the POSIX locale
57              an [EILSEQ] error cannot occur since all byte values  are  valid
58              characters.
59
60       The following sections are informative.
61

EXAMPLES

63       None.
64

APPLICATION USAGE

66       None.
67

RATIONALE

69       None.
70

FUTURE DIRECTIONS

72       None.
73

SEE ALSO

75       mblen(), mbtowc(), wctomb(), wcstombs()
76
77       The Base Definitions volume of POSIX.1‐2017, <stdlib.h>
78
80       Portions  of  this text are reprinted and reproduced in electronic form
81       from IEEE Std 1003.1-2017, Standard for Information Technology --  Por‐
82       table  Operating System Interface (POSIX), The Open Group Base Specifi‐
83       cations Issue 7, 2018 Edition, Copyright (C) 2018 by the  Institute  of
84       Electrical  and  Electronics Engineers, Inc and The Open Group.  In the
85       event of any discrepancy between this version and the original IEEE and
86       The  Open Group Standard, the original IEEE and The Open Group Standard
87       is the referee document. The original Standard can be  obtained  online
88       at http://www.opengroup.org/unix/online.html .
89
90       Any  typographical  or  formatting  errors that appear in this page are
91       most likely to have been introduced during the conversion of the source
92       files  to  man page format. To report such errors, see https://www.ker
93       nel.org/doc/man-pages/reporting_bugs.html .
94
95
96
97IEEE/The Open Group                  2017                         MBSTOWCS(3P)
Impressum