]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright (c) Bruno Haible <haible@clisp.cons.org> |
2 | .\" | |
e4a74ca8 | 3 | .\" SPDX-License-Identifier: GPL-2.0-or-later |
fea681da MK |
4 | .\" |
5 | .\" References consulted: | |
6 | .\" GNU glibc-2 source code and manual | |
7 | .\" Dinkumware C library reference http://www.dinkumware.com/ | |
008f1ecc | 8 | .\" OpenGroup's Single UNIX specification http://www.UNIX-systems.org/online.html |
fea681da MK |
9 | .\" ISO/IEC 9899:1999 |
10 | .\" | |
4c1c5274 | 11 | .TH wctomb 3 (date) "Linux man-pages (unreleased)" |
fea681da MK |
12 | .SH NAME |
13 | wctomb \- convert a wide character to a multibyte sequence | |
f3cdb40a AC |
14 | .SH LIBRARY |
15 | Standard C library | |
8fc3b2cf | 16 | .RI ( libc ", " \-lc ) |
fea681da MK |
17 | .SH SYNOPSIS |
18 | .nf | |
19 | .B #include <stdlib.h> | |
68e4db0a | 20 | .PP |
fea681da MK |
21 | .BI "int wctomb(char *" s ", wchar_t " wc ); |
22 | .fi | |
23 | .SH DESCRIPTION | |
35cfd378 MK |
24 | If |
25 | .I s | |
26 | is not NULL, | |
60a90ecd MK |
27 | the |
28 | .BR wctomb () | |
29 | function converts the wide character | |
35cfd378 MK |
30 | .I wc |
31 | to its multibyte representation and stores it at the beginning of | |
32 | the character array pointed to by | |
33 | .IR s . | |
c13182ef MK |
34 | It updates the shift state, which |
35 | is stored in a static anonymous variable | |
33a0ccb2 | 36 | known only to the |
8c917f5c MK |
37 | .BR wctomb () |
38 | function, | |
c13182ef | 39 | and returns the length of said multibyte representation, |
75b94dc3 | 40 | that is, the number of |
35cfd378 MK |
41 | bytes written at |
42 | .IR s . | |
fea681da | 43 | .PP |
c13182ef | 44 | The programmer must ensure that there is |
35cfd378 MK |
45 | room for at least |
46 | .B MB_CUR_MAX | |
47 | bytes at | |
48 | .IR s . | |
fea681da | 49 | .PP |
35cfd378 MK |
50 | If |
51 | .I s | |
52 | is NULL, the | |
60a90ecd MK |
53 | .BR wctomb () |
54 | function | |
008f1ecc | 55 | .\" The Dinkumware doc and the Single UNIX specification say this, but |
fea681da | 56 | .\" glibc doesn't implement this. |
33a0ccb2 | 57 | resets the shift state, known only to this function, |
c13182ef | 58 | to the initial state, and |
c7094399 | 59 | returns nonzero if the encoding has nontrivial shift state, |
c13182ef | 60 | or zero if the encoding is stateless. |
47297adb | 61 | .SH RETURN VALUE |
35cfd378 MK |
62 | If |
63 | .I s | |
64 | is not NULL, the | |
60a90ecd MK |
65 | .BR wctomb () |
66 | function | |
c13182ef | 67 | returns the number of bytes |
35cfd378 MK |
68 | that have been written to the byte array at |
69 | .IR s . | |
70 | If | |
71 | .I wc | |
72 | can not be | |
c13182ef MK |
73 | represented as a multibyte sequence (according |
74 | to the current locale), \-1 is returned. | |
fea681da | 75 | .PP |
35cfd378 MK |
76 | If |
77 | .I s | |
78 | is NULL, the | |
60a90ecd | 79 | .BR wctomb () |
c7094399 | 80 | function returns nonzero if the |
c382a365 | 81 | encoding has nontrivial shift state, or zero if the encoding is stateless. |
69e8f02f | 82 | .SH ATTRIBUTES |
bcd70a87 PH |
83 | For an explanation of the terms used in this section, see |
84 | .BR attributes (7). | |
c466875e MK |
85 | .ad l |
86 | .nh | |
bcd70a87 PH |
87 | .TS |
88 | allbox; | |
c466875e | 89 | lbx lb lb |
bcd70a87 PH |
90 | l l l. |
91 | Interface Attribute Value | |
92 | T{ | |
69e8f02f | 93 | .BR wctomb () |
8ff1e928 | 94 | T} Thread safety MT-Unsafe race |
bcd70a87 | 95 | .TE |
c466875e MK |
96 | .hy |
97 | .ad | |
98 | .sp 1 | |
3113c7f3 | 99 | .SH STANDARDS |
f6221652 | 100 | POSIX.1-2001, POSIX.1-2008, C99. |
fea681da | 101 | .SH NOTES |
d9bfdb9c | 102 | The behavior of |
60a90ecd | 103 | .BR wctomb () |
1274071a MK |
104 | depends on the |
105 | .B LC_CTYPE | |
106 | category of the | |
fea681da MK |
107 | current locale. |
108 | .PP | |
60a90ecd MK |
109 | The function |
110 | .BR wcrtomb (3) | |
111 | provides | |
fea681da | 112 | a better interface to the same functionality. |
47297adb | 113 | .SH SEE ALSO |
e37e3282 | 114 | .BR MB_CUR_MAX (3), |
4670051b MK |
115 | .BR mblen (3), |
116 | .BR mbstowcs (3), | |
117 | .BR mbtowc (3), | |
e37e3282 MK |
118 | .BR wcrtomb (3), |
119 | .BR wcstombs (3) |