]>
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 wcstombs 3 (date) "Linux man-pages (unreleased)" |
fea681da | 12 | .SH NAME |
d0f17b57 | 13 | wcstombs \- convert a wide-character string to a multibyte string |
cd8b08b0 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 |
7ce7d2ad AC |
21 | .BI "size_t wcstombs(char *restrict " dest ", const wchar_t *restrict " src , |
22 | .BI " size_t " n ); | |
fea681da MK |
23 | .fi |
24 | .SH DESCRIPTION | |
40aa0db0 MK |
25 | If |
26 | .I dest | |
b437fdd9 | 27 | is not NULL, the |
60a90ecd MK |
28 | .BR wcstombs () |
29 | function converts | |
40aa0db0 MK |
30 | the wide-character string |
31 | .I src | |
32 | to a multibyte string starting at | |
33 | .IR dest . | |
34 | At most | |
35 | .I n | |
36 | bytes are written to | |
37 | .IR dest . | |
3942b6bc | 38 | The sequence of characters placed in |
1ae6b2c7 | 39 | .I dest |
3942b6bc | 40 | begins in the initial shift state. |
c13182ef | 41 | The conversion can stop for three reasons: |
22356d97 | 42 | .IP \(bu 3 |
db59590e | 43 | A wide character has been encountered that can not be represented as a |
c13182ef | 44 | multibyte sequence (according to the current locale). |
9218ef3d | 45 | In this case, |
009df872 | 46 | .I (size_t)\ \-1 |
7d2cb9d5 | 47 | is returned. |
22356d97 | 48 | .IP \(bu |
db59590e | 49 | The length limit forces a stop. |
441efbb7 | 50 | In this case, the number of bytes written to |
40aa0db0 MK |
51 | .I dest |
52 | is returned, but the shift state at this point is lost. | |
22356d97 | 53 | .IP \(bu |
db59590e | 54 | The wide-character string has been completely converted, including the |
d1a71985 | 55 | terminating null wide character (L\(aq\e0\(aq). |
3942b6bc | 56 | In this case, the conversion ends in the initial shift state. |
40aa0db0 MK |
57 | The number of bytes written to |
58 | .IR dest , | |
d1a71985 | 59 | excluding the terminating null byte (\(aq\e0\(aq), is returned. |
fea681da | 60 | .PP |
40aa0db0 MK |
61 | The programmer must ensure that there is room for at least |
62 | .I n | |
63 | bytes | |
64 | at | |
65 | .IR dest . | |
fea681da | 66 | .PP |
40aa0db0 | 67 | If |
1ae6b2c7 | 68 | .I dest |
40aa0db0 MK |
69 | is NULL, |
70 | .I n | |
71 | is ignored, and the conversion proceeds as | |
fb186734 | 72 | above, except that the converted bytes are not written out to memory, |
d75efe73 | 73 | and no length limit exists. |
fea681da | 74 | .PP |
40aa0db0 MK |
75 | In order to avoid the case 2 above, the programmer should make sure |
76 | .I n | |
d75efe73 | 77 | is greater than or equal to |
40aa0db0 | 78 | .IR "wcstombs(NULL,src,0)+1" . |
47297adb | 79 | .SH RETURN VALUE |
60a90ecd MK |
80 | The |
81 | .BR wcstombs () | |
82 | function returns the number of bytes that make up the | |
d75efe73 MK |
83 | converted part of a multibyte sequence, |
84 | not including the terminating null byte. | |
fb186734 | 85 | If a wide character was encountered which could not be |
7d2cb9d5 | 86 | converted, |
009df872 | 87 | .I (size_t)\ \-1 |
7d2cb9d5 | 88 | is returned. |
b640fcfa MS |
89 | .SH ATTRIBUTES |
90 | For an explanation of the terms used in this section, see | |
91 | .BR attributes (7). | |
c466875e MK |
92 | .ad l |
93 | .nh | |
b640fcfa MS |
94 | .TS |
95 | allbox; | |
c466875e | 96 | lbx lb lb |
b640fcfa MS |
97 | l l l. |
98 | Interface Attribute Value | |
99 | T{ | |
100 | .BR wcstombs () | |
101 | T} Thread safety MT-Safe | |
102 | .TE | |
c466875e MK |
103 | .hy |
104 | .ad | |
847e0d88 | 105 | .sp 1 |
3113c7f3 | 106 | .SH STANDARDS |
6d2e3caf | 107 | POSIX.1-2001, POSIX.1-2008, C99. |
fea681da | 108 | .SH NOTES |
d9bfdb9c | 109 | The behavior of |
60a90ecd | 110 | .BR wcstombs () |
1274071a MK |
111 | depends on the |
112 | .B LC_CTYPE | |
113 | category of the | |
fea681da MK |
114 | current locale. |
115 | .PP | |
60a90ecd MK |
116 | The function |
117 | .BR wcsrtombs (3) | |
fdcc06ee | 118 | provides a better interface to the same functionality. |
47297adb | 119 | .SH SEE ALSO |
4670051b | 120 | .BR mblen (3), |
49438ab7 | 121 | .BR mbstowcs (3), |
ca38b869 | 122 | .BR mbtowc (3), |
bba4bbbd | 123 | .BR wcsrtombs (3), |
e8b81d34 | 124 | .BR wctomb (3) |