1WCTOMB(3) Linux Programmer's Manual WCTOMB(3)
2
3
4
6 wctomb - convert a wide character to a multibyte sequence
7
9 #include <stdlib.h>
10
11 int wctomb(char *s, wchar_t wc);
12
14 If s is not NULL, the wctomb() function converts the wide character wc
15 to its multibyte representation and stores it at the beginning of the
16 character array pointed to by s. It updates the shift state, which is
17 stored in a static anonymous variable known only to the wctomb() func‐
18 tion, and returns the length of said multibyte representation, that is,
19 the number of bytes written at s.
20
21 The programmer must ensure that there is room for at least MB_CUR_MAX
22 bytes at s.
23
24 If s is NULL, the wctomb() function resets the shift state, known only
25 to this function, to the initial state, and returns nonzero if the en‐
26 coding has nontrivial shift state, or zero if the encoding is state‐
27 less.
28
30 If s is not NULL, the wctomb() function returns the number of bytes
31 that have been written to the byte array at s. If wc can not be repre‐
32 sented as a multibyte sequence (according to the current locale), -1 is
33 returned.
34
35 If s is NULL, the wctomb() function returns nonzero if the encoding has
36 nontrivial shift state, or zero if the encoding is stateless.
37
39 For an explanation of the terms used in this section, see at‐
40 tributes(7).
41
42 ┌──────────┬───────────────┬────────────────┐
43 │Interface │ Attribute │ Value │
44 ├──────────┼───────────────┼────────────────┤
45 │wctomb() │ Thread safety │ MT-Unsafe race │
46 └──────────┴───────────────┴────────────────┘
48 POSIX.1-2001, POSIX.1-2008, C99.
49
51 The behavior of wctomb() depends on the LC_CTYPE category of the cur‐
52 rent locale.
53
54 The function wcrtomb(3) provides a better interface to the same func‐
55 tionality.
56
58 MB_CUR_MAX(3), mblen(3), mbstowcs(3), mbtowc(3), wcrtomb(3), wc‐
59 stombs(3)
60
62 This page is part of release 5.10 of the Linux man-pages project. A
63 description of the project, information about reporting bugs, and the
64 latest version of this page, can be found at
65 https://www.kernel.org/doc/man-pages/.
66
67
68
69GNU 2015-08-08 WCTOMB(3)