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       #define _GNU_SOURCE
10       #include <wchar.h>
11
12       size_t wcsnrtombs(char *dest, const wchar_t **src, size_t nwc,
13                         size_t len, mbstate_t *ps);
14

DESCRIPTION

16       The  wcsnrtombs()  function  is  like the wcsrtombs(3) function, except
17       that the number of wide characters to be converted, starting  at  *src,
18       is limited to nwc.
19
20       If  dest  is  not a NULL pointer, the wcsnrtombs() function converts at
21       most nwc wide characters from  the  wide-character  string  *src  to  a
22       multibyte  string  starting  at dest.  At most len bytes are written to
23       dest.  The shift state *ps is updated.  The conversion  is  effectively
24       performed  by  repeatedly  calling  wcrtomb(dest, *src, ps), as long as
25       this call succeeds, and then incrementing dest by the number  of  bytes
26       written and *src by one.  The conversion can stop for three reasons:
27
28       1. A wide character has been encountered that can not be represented as
29       a multibyte sequence (according to the current locale).  In  this  case
30       *src  is  left  pointing  to the invalid wide character, (size_t) -1 is
31       returned, and errno is set to EILSEQ.
32
33       2. nwc wide characters  have  been  converted  without  encountering  a
34       L'\0',  or  the  length limit forces a stop.  In this case *src is left
35       pointing to the next wide character to be converted, and the number  of
36       bytes written to dest is returned.
37
38       3.  The  wide-character string has been completely converted, including
39       the terminating L'\0' (which has the side effect of bringing  back  *ps
40       to  the initial state).  In this case *src is set to NULL, and the num‐
41       ber of bytes written to dest, excluding the terminating '\0'  byte,  is
42       returned.
43
44       If  dest is NULL, len is ignored, and the conversion proceeds as above,
45       except that the converted bytes are not written out to memory, and that
46       no destination length limit exists.
47
48       In both of the above cases, if ps is a NULL pointer, a static anonymous
49       state only known to the wcsnrtombs function is used instead.
50
51       The programmer must ensure that there is room for at least len bytes at
52       dest.
53

RETURN VALUE

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

CONFORMING TO

61       This function is a GNU extension.
62

NOTES

64       The behavior of wcsnrtombs() depends on the LC_CTYPE  category  of  the
65       current locale.
66
67       Passing NULL as ps is not multithread safe.
68

SEE ALSO

70       iconv(3), wcsrtombs(3)
71

COLOPHON

73       This  page  is  part of release 3.25 of the Linux man-pages project.  A
74       description of the project, and information about reporting  bugs,  can
75       be found at http://www.kernel.org/doc/man-pages/.
76
77
78
79GNU                               2007-07-26                     WCSNRTOMBS(3)
Impressum