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

NAME

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

SYNOPSIS

9       #include <wchar.h>
10
11       size_t wcsnrtombs(char *dest, const wchar_t **src, size_t nwc,
12                         size_t len, mbstate_t *ps);
13
14   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
15
16       wcsnrtombs():
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  wcsnrtombs()  function  is  like the wcsrtombs(3) function, except
24       that the number of wide characters to be converted, starting  at  *src,
25       is limited to nwc.
26
27       If  dest  is  not a NULL pointer, the wcsnrtombs() function converts at
28       most nwc wide characters from  the  wide-character  string  *src  to  a
29       multibyte  string  starting  at dest.  At most len bytes are written to
30       dest.  The shift state *ps is updated.  The conversion  is  effectively
31       performed  by  repeatedly  calling  wcrtomb(dest, *src, ps), as long as
32       this call succeeds, and then incrementing dest by the number  of  bytes
33       written and *src by one.  The conversion can stop for three reasons:
34
35       1. A wide character has been encountered that can not be represented as
36          a multibyte sequence (according to the  current  locale).   In  this
37          case   *src   is  left  pointing  to  the  invalid  wide  character,
38          (size_t) -1 is returned, and errno is set to EILSEQ.
39
40       2. nwc wide characters have been converted without encountering a  null
41          wide  character (L'\0'), or the length limit forces a stop.  In this
42          case *src is left pointing to the next wide  character  to  be  con‐
43          verted, and the number of bytes written to dest is returned.
44
45       3. The  wide-character  string has been completely converted, including
46          the terminating null wide character (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 bytes written to dest, excluding the ter‐
49          minating null byte ('\0'), is returned.
50
51       If  dest is NULL, len is ignored, and the conversion proceeds as above,
52       except that the converted bytes are not written out to memory, and that
53       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 wcsnrtombs() function is used instead.
57
58       The programmer must ensure that there is room for at least len bytes at
59       dest.
60

RETURN VALUE

62       The  wcsnrtombs() function returns the number of bytes that make up the
63       converted part of multibyte sequence,  not  including  the  terminating
64       null byte.  If a wide character was encountered which could not be con‐
65       verted, (size_t) -1 is returned, and errno set to EILSEQ.
66

CONFORMING TO

68       POSIX.1-2008.
69

NOTES

71       The behavior of wcsnrtombs() 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), wcsrtombs(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-16                     WCSNRTOMBS(3)
Impressum