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

NAME

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

SYNOPSIS

9       #include <wchar.h>
10
11       size_t mbsnrtowcs(wchar_t *dest, const char **src,
12                         size_t nms, size_t len, mbstate_t *ps);
13
14   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
15
16       mbsnrtowcs():
17           Since glibc 2.10:
18               _XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L
19           Before glibc 2.10:
20               _GNU_SOURCE
21

DESCRIPTION

23       The  mbsnrtowcs()  function  is  like the mbsrtowcs(3) function, except
24       that the number of bytes to be converted, starting at *src, is  limited
25       to nms.
26
27       If  dest  is  not a NULL pointer, the mbsnrtowcs() function converts at
28       most nms bytes from the  multibyte  string  *src  to  a  wide-character
29       string  starting  at  dest.  At most len wide characters are written to
30       dest.  The shift state *ps is updated.  The conversion  is  effectively
31       performed  by  repeatedly calling mbrtowc(dest, *src, n, ps) where n is
32       some positive number, as long as this call succeeds,  and  then  incre‐
33       menting dest by one and *src by the number of bytes consumed.  The con‐
34       version can stop for three reasons:
35
36       1. An invalid multibyte sequence has been encountered.   In  this  case
37          *src is left pointing to the invalid multibyte sequence, (size_t) -1
38          is returned, and errno is set to EILSEQ.
39
40       2. The nms limit forces a stop, or len non-L'\0' wide  characters  have
41          been stored at dest.  In this case *src is left pointing to the next
42          multibyte sequence to be converted, and the number of  wide  charac‐
43          ters written to dest is returned.
44
45       3. The  multibyte  string  has been completely converted, including the
46          terminating null wide character ('\0') (which has the side effect of
47          bringing  back  *ps to the initial state).  In this case *src is set
48          to NULL, and the number of wide characters written to dest,  exclud‐
49          ing the terminating null wide character, is returned.
50
51       If  dest is NULL, len is ignored, and the conversion proceeds as above,
52       except that the converted wide characters are not written out  to  mem‐
53       ory, and that no destination length limit exists.
54
55       In both of the above cases, if ps is a NULL pointer, a static anonymous
56       state known only to the mbsnrtowcs() function is used instead.
57
58       The programmer must ensure that there is room for  at  least  len  wide
59       characters at dest.
60

RETURN VALUE

62       The  mbsnrtowcs()  function  returns the number of wide characters that
63       make up the converted part of the wide-character string, not  including
64       the  terminating null wide character.  If an invalid multibyte sequence
65       was encountered, (size_t) -1 is returned, and errno set to EILSEQ.
66

CONFORMING TO

68       POSIX.1-2008.
69

NOTES

71       The behavior of mbsnrtowcs() depends on the LC_CTYPE  category  of  the
72       current locale.
73
74       Passing NULL as ps is not multithread safe.
75

SEE ALSO

77       iconv(3), mbsrtowcs(3)
78

COLOPHON

80       This  page  is  part of release 3.53 of the Linux man-pages project.  A
81       description of the project, and information about reporting  bugs,  can
82       be found at http://www.kernel.org/doc/man-pages/.
83
84
85
86GNU                               2011-10-01                     MBSNRTOWCS(3)
Impressum