1wctomb(3)                  Library Functions Manual                  wctomb(3)
2
3
4

NAME

6       wctomb - convert a wide character to a multibyte sequence
7

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

12       #include <stdlib.h>
13
14       int wctomb(char *s, wchar_t wc);
15

DESCRIPTION

17       If  s is not NULL, the wctomb() function converts the wide character wc
18       to its multibyte representation and stores it at the beginning  of  the
19       character  array pointed to by s.  It updates the shift state, which is
20       stored in a static anonymous variable known only to the wctomb()  func‐
21       tion, and returns the length of said multibyte representation, that is,
22       the number of bytes written at s.
23
24       The programmer must ensure that there is room for at  least  MB_CUR_MAX
25       bytes at s.
26
27       If  s is NULL, the wctomb() function resets the shift state, known only
28       to this function, to the initial state, and returns nonzero if the  en‐
29       coding  has  nontrivial  shift state, or zero if the encoding is state‐
30       less.
31

RETURN VALUE

33       If s is not NULL, the wctomb() function returns  the  number  of  bytes
34       that have been written to the byte array at s.  If wc can not be repre‐
35       sented as a multibyte sequence (according to the current locale), -1 is
36       returned.
37
38       If s is NULL, the wctomb() function returns nonzero if the encoding has
39       nontrivial shift state, or zero if the encoding is stateless.
40

ATTRIBUTES

42       For an  explanation  of  the  terms  used  in  this  section,  see  at‐
43       tributes(7).
44
45       ┌─────────────────────────────────────┬───────────────┬────────────────┐
46Interface                            Attribute     Value          
47       ├─────────────────────────────────────┼───────────────┼────────────────┤
48wctomb()                             │ Thread safety │ MT-Unsafe race │
49       └─────────────────────────────────────┴───────────────┴────────────────┘
50

VERSIONS

52       The  function  wcrtomb(3)  provides  a  better  interface  to  the same
53       functionality.
54

STANDARDS

56       C11, POSIX.1-2008.
57

HISTORY

59       POSIX.1-2001, C99.
60

NOTES

62       The behavior of wctomb()  depends  on  the  LC_CTYPE  category  of  the
63       current locale.
64

SEE ALSO

66       MB_CUR_MAX(3),    mblen(3),    mbstowcs(3),    mbtowc(3),   wcrtomb(3),
67       wcstombs(3)
68
69
70
71Linux man-pages 6.05              2023-07-20                         wctomb(3)
Impressum