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               _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 at most nms bytes.
26
27       If  dest  is  not  NULL, the mbsnrtowcs() function converts at most nms
28       bytes from the multibyte string *src to a wide-character string  start‐
29       ing  at  dest.   At  most len wide characters are written to dest.  The
30       shift state *ps is updated.  The conversion is effectively performed by
31       repeatedly  calling mbrtowc(dest, *src, n, ps) where n is some positive
32       number, as long as this call succeeds, and then  incrementing  dest  by
33       one  and *src by the number of bytes consumed.  The conversion can stop
34       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
42          next multibyte sequence to be converted,  and  the  number  of  wide
43          characters 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       According to POSIX.1, if the input buffer ends with an incomplete char‐
52       acter, it is unspecified whether conversion stops at  the  end  of  the
53       previous  character  (if  any), or at the end of the input buffer.  The
54       glibc implementation adopts the former behavior.
55
56       If dest is NULL, len is ignored, and the conversion proceeds as  above,
57       except  that  the converted wide characters are not written out to mem‐
58       ory, and that no destination length limit exists.
59
60       In both of the above cases, if ps is NULL,  a  static  anonymous  state
61       known only to the mbsnrtowcs() function is used instead.
62
63       The  programmer  must  ensure  that there is room for at least len wide
64       characters at dest.
65

RETURN VALUE

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

ATTRIBUTES

73       For   an   explanation   of   the  terms  used  in  this  section,  see
74       attributes(7).
75
76       ┌─────────────┬───────────────┬───────────────────────────────┐
77Interface    Attribute     Value                         
78       ├─────────────┼───────────────┼───────────────────────────────┤
79mbsnrtowcs() │ Thread safety │ MT-Unsafe race:mbsnrtowcs/!ps │
80       └─────────────┴───────────────┴───────────────────────────────┘
81

CONFORMING TO

83       POSIX.1-2008.
84

NOTES

86       The behavior of mbsnrtowcs() depends on the LC_CTYPE  category  of  the
87       current locale.
88
89       Passing NULL as ps is not multithread safe.
90

SEE ALSO

92       iconv(3), mbrtowc(3) mbsinit(3), mbsrtowcs(3)
93

COLOPHON

95       This  page  is  part of release 5.04 of the Linux man-pages project.  A
96       description of the project, information about reporting bugs,  and  the
97       latest     version     of     this    page,    can    be    found    at
98       https://www.kernel.org/doc/man-pages/.
99
100
101
102GNU                               2019-03-06                     MBSNRTOWCS(3)
Impressum