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 written to
28       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

SEE ALSO

50       mbsrtowcs(3)
51

NOTES

53       The behaviour of mbstowcs() depends on the  LC_CTYPE  category  of  the
54       current locale.
55
56       The  function mbsrtowcs() provides a better interface to the same func‐
57       tionality.
58
59
60
61GNU                               1999-07-25                       MBSTOWCS(3)
Impressum