1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
.\"
.\" This file and its contents are supplied under the terms of the
.\" Common Development and Distribution License ("CDDL"), version 1.0.
.\" You may only use this file in accordance with the terms of version
.\" 1.0 of the CDDL.
.\"
.\" A full copy of the text of the CDDL should have accompanied this
.\" source. A copy of the CDDL is also available via the Internet at
.\" http://www.illumos.org/license/CDDL.
.\"
.\"
.\" Copyright 2017 Nexenta Systems, Inc.
.\"
.Dd March 28, 2017
.Dt WCSTOMBS 3C
.Os
.Sh NAME
.Nm wcstombs ,
.Nm wcstombs_l
.Nd convert a wide-character string to a multibyte character string
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.In stdlib.h
.Ft size_t
.Fo wcstombs
.Fa "char *restrict s"
.Fa "const wchar_t *restrict pwcs"
.Fa "size_t n"
.Fc
.In stdlib.h
.In xlocale.h
.Ft size_t
.Fo wcstombs_l
.Fa "char *restrict s"
.Fa "const wchar_t *restrict pwcs"
.Fa "size_t n"
.Fa "locale_t loc"
.Fc
.Sh DESCRIPTION
The
.Fn wcstombs
function converts a wide-character string
.Fa pwcs
into a multibyte character string, beginning in the initial conversion state.
If
.Fa s
is not
.Dv NULL ,
converted characters are stored into the array pointed to by
.Fa s .
.Pp
Conversion continues up to and including a terminating null wide-character,
which is also stored, or until
.Fa n
bytes have been stored into the array pointed to by
.Fa s .
If the latter case results in partial multibyte character at the end of the
string, it is not stored.
.Pp
The behavior of
.Fn wcstombs
function is affected by the
.Ev LC_CTYPE
category of the current locale.
.Pp
The
.Fn wcstombs_l
function behaves identically to
.Fn wcstombs ,
except instead of using the current locale, it uses the locale as specified by
.Fa loc .
.Sh RETURN VALUES
The
.Fn wcstombs
and
.Fn wcstombs_l
functions return the number of bytes in the resulting character sequence, not
including the terminating null
.Pq if any ,
or
.Li \-1
if a code is reached that does not correspond to a valid character.
.Sh ERRORS
The
.Fn wcstombs
and
.Fn wcstombs_l
functions will fail if:
.Bl -tag -width Er
.It Er EILSEQ
A wide-character code does not correspond to a valid character.
.It Er EINVAL
The conversion state is invalid.
.El
.Sh INTERFACE STABILITY
The
.Fn wcstombs
function is
.Sy Standard .
The
.Fn wcstombs_l
function is
.Sy Uncommitted .
.Sh MT-LEVEL
.Sy MT-Safe
.Sh SEE ALSO
.Xr mbstowcs 3C ,
.Xr newlocale 3C ,
.Xr setlocale 3C ,
.Xr uselocale 3C ,
.Xr wcsnrtombs 3C ,
.Xr wctomb 3C ,
.Xr attributes 5 ,
.Xr environ 5 ,
.Xr standards 5
|