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 '\0'.  In this case the number of wide characters  writ‐
28          ten to dest, excluding the terminating L'\0' character, is returned.
29
30       The programmer must ensure that there is room for at least n wide char‐
31       acters at dest.
32
33       If dest is NULL, n is ignored, and the conversion  proceeds  as  above,
34       except  that  the converted wide characters are not written out to mem‐
35       ory, and that no length limit exists.
36
37       In order to avoid the case 2 above, the programmer should make  sure  n
38       is greater or equal to mbstowcs(NULL,src,0)+1.
39

RETURN VALUE

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

CONFORMING TO

47       C99.
48

NOTES

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

SEE ALSO

57       mbsrtowcs(3)
58

COLOPHON

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