1MBSTOWCS(3)                Linux Programmer's Manual               MBSTOWCS(3)
2
3
4

NAME

6       mbstowcs - convert a multibyte string to a wide-character string
7

SYNOPSIS

9       #include <stdlib.h>
10
11       size_t mbstowcs(wchar_t *dest, const char *src, size_t n);
12

DESCRIPTION

14       If  dest  is  not  a NULL pointer, the mbstowcs() function converts the
15       multibyte string src to a wide-character string starting at  dest.   At
16       most  n  wide characters are written to dest.  The conversion starts in
17       the initial state.  The conversion can stop for three reasons:
18
19       1. An invalid multibyte sequence has been encountered.   In  this  case
20          (size_t) -1 is returned.
21
22       2. n  non-L'\0' wide characters have been stored at dest.  In this case
23          the number of wide characters written to dest is returned,  but  the
24          shift state at this point is lost.
25
26       3. The  multibyte  string  has been completely converted, including the
27          terminating null wide character ('\0').  In this case the number  of
28          wide characters written to dest, excluding the terminating null wide
29          character, is returned.
30
31       The programmer must ensure that there is room for at least n wide char‐
32       acters at dest.
33
34       If  dest  is  NULL, n is ignored, and the conversion proceeds as above,
35       except that the converted wide characters are not written out  to  mem‐
36       ory, and that no length limit exists.
37
38       In  order  to avoid the case 2 above, the programmer should make sure n
39       is greater or equal to mbstowcs(NULL,src,0)+1.
40

RETURN VALUE

42       The mbstowcs() function returns the number of wide characters that make
43       up  the  converted part of the wide-character string, not including the
44       terminating null wide character.  If an invalid multibyte sequence  was
45       encountered, (size_t) -1 is returned.
46

CONFORMING TO

48       C99.
49

NOTES

51       The behavior of mbstowcs() depends on the LC_CTYPE category of the cur‐
52       rent locale.
53
54       The function mbsrtowcs(3) provides a better interface to the same func‐
55       tionality.
56

SEE ALSO

58       mbsrtowcs(3), wcstombs(3)
59

COLOPHON

61       This  page  is  part of release 3.53 of the Linux man-pages project.  A
62       description of the project, and information about reporting  bugs,  can
63       be found at http://www.kernel.org/doc/man-pages/.
64
65
66
67GNU                               2011-09-28                       MBSTOWCS(3)
Impressum