Print this page
5025 import and use mandoc
Reviewed by: Hans Rosenfeld <hans.rosenfeld@nexenta.com>
Reviewed by: Igor Kozhukhov <ikozhukhov@gmail.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Albert Lee <trisk@nexenta.com>
Approved by: TBD
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/man/man3c/mbrtowc.3c
+++ new/usr/src/man/man3c/mbrtowc.3c
1 1 '\" te
2 2 .\" Copyright 2014 Garrett D'Amore <garrett@damore.org>
3 3 .\" Copyright (c) 1992, X/Open Company Limited. All Rights Reserved. Portions Copyright (c) 2003, Sun Microsystems, Inc. All Rights Reserved.
4 4 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
5 5 .\" http://www.opengroup.org/bookstore/.
6 6 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
7 7 .\" This notice shall appear on any product containing this material.
8 8 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
9 9 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
10 10 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
11 11 .TH MBRTOWC 3C "Jun 23, 2014"
12 12 .SH NAME
13 13 mbrtowc, mbrtowc_l \- convert a character to a wide-character code (restartable)
14 14 .SH SYNOPSIS
15 15 .LP
16 16 .nf
17 17 #include <wchar.h>
18 18
19 19 \fBsize_t\fR \fBmbrtowc\fR(\fBwchar_t *restrict\fR \fIpwc\fR, \fBconst char *restrict\fR \fIs\fR, \fBsize_t\fR \fIn\fR,
20 20 \fBmbstate_t *restrict\fR \fIps\fR);
21 21 .fi
22 22 .LP
23 23 .nf
24 24 #include <wchar.h>
25 25 #include <xlocale.h>
26 26
27 27 \fBsize_t\fR \fBmbrtowc_l\fR(\fBwchar_t *restrict\fR \fIpwc\fR, \fBconst char *restrict\fR \fIs\fR, \fBsize_t\fR \fIn\fR,
28 28 \fBmbstate_t *restrict\fR \fIps\fR, \fBlocale_t\fR \fIloc\fR);
29 29 .fi
30 30 .SH DESCRIPTION
31 31 .LP
32 32 If
33 33 .I s
34 34 is a null pointer, the
35 35 .B mbrtowc()
36 36 function is equivalent to the call:
37 37 .sp
38 38 .in +2
39 39 .nf
40 40 \fBmbrtowc\fR(NULL, "", 1, \fIps\fR)
41 41 .fi
42 42 .in -2
43 43 .LP
44 44 Likewise, if
45 45 .I s
46 46 is a null pointer, the
47 47 .B mbrtowc_l()
48 48 function is equivalent to the call:
49 49 .sp
50 50 .in +2
51 51 .nf
52 52 \fBmbrtowc_l\fR(NULL, "", 1, \fIps\fR, \fIloc\fR);
53 53 .fi
54 54 .in -2
55 55 .LP
56 56 In these cases, the values of the arguments
57 57 .I pwc
58 58 and
59 59 .I n
60 60 are ignored.
61 61 .LP
62 62 If
63 63 .I s
64 64 is not a null pointer, these functions inspect at most
65 65 .I n
66 66 bytes beginning at the byte pointed to by
67 67 .I s
68 68 to determine the number of bytes needed to complete the next character
69 69 (including any shift sequences). If the functions determine that the next
70 70 character is completed,
71 71 they determine the value of the corresponding wide-character and then, if
72 72 .I pwc
73 73 is not a null pointer, stores that value in the object pointed to by
↓ open down ↓ |
73 lines elided |
↑ open up ↑ |
74 74 .IR pwc .
75 75 If the corresponding wide-character is the null wide-character, the
76 76 resulting state described is the initial conversion state.
77 77 .LP
78 78 If
79 79 .I ps
80 80 is a null pointer, these functions use their own
81 81 internal
82 82 .B mbstate_t
83 83 object, which is initialized at program startup to the
84 -initial conversion state. Otherwise, the
84 +initial conversion state. Otherwise, the
85 85 .B mbstate_t
86 86 object pointed to by
87 87 .I ps
88 88 is used to completely describe the current conversion state of the
89 89 associated character sequence. The system will behave as if no function defined
90 90 in the Reference Manual calls
91 91 .B mbrtowc()
92 92 or
93 93 .BR Bmbrtowc_l() .
94 94 .LP
95 95 The behavior of
96 96 .B mbrtowc()
97 97 is affected by the
98 98 .B LC_CTYPE
99 99 category of the current locale. The
100 100 .B mbrtowc_l()
101 101 function is affected by the
102 102 .B LC_CTYPE
103 103 category of the specified
104 104 .I loc
105 105 locale object. See
106 106 .B environ (5).
107 107 .SH RETURN VALUES
108 108 .LP
109 109 The
110 110 .B mbrtowc()
111 111 and
112 112 .B mbrtowc_l()
113 113 functions return the first of the following that applies:
114 114 .IP \fB0\fR
115 115 If the next
116 116 .I n
117 117 or fewer bytes complete the character that corresponds to
118 118 the null wide-character (which is the value stored).
119 119 .IP \fBpositive\fR
120 120 If the next
121 121 .I n
122 122 or fewer bytes complete a valid character (which is the
123 123 value stored); the value returned is the number of bytes that complete the
124 124 character.
125 125 .IP \fB(size_t)\(mi2\fR
126 126 If the next
127 127 .I n
128 128 bytes contribute to an incomplete but potentially valid
129 129 character, and all
130 130 .I n
131 131 bytes have been processed (no value is stored).
132 132 When
133 133 .I n
134 134 has at least the value of the
135 135 .B MB_CUR_MAX
136 136 macro, this case can only occur if
137 137 .I s
138 138 points at a sequence of redundant shift sequences
139 139 (for implementations with state-dependent encodings).
140 140 .IP \fB(size_t)\(mi1\fR
141 141 If an encoding error occurs, in which case the next \fIn\fR or fewer bytes do
142 142 not contribute to a complete and valid character (no value is stored). In
143 143 this case,
144 144 .B EILSEQ
145 145 is stored in
146 146 .B errno
147 147 and the conversion state is undefined.
148 148 .SH ERRORS
149 149 .LP
150 150 The
151 151 .B mbrtowc()
152 152 and
153 153 .B mbrtowc_l()
154 154 functions may fail if:
155 155 .IP \fBEINVAL\fR
156 156 The
157 157 .I ps
158 158 argument points to an object that contains an invalid conversion
159 159 state.
160 160 .IP \fBEILSEQ\fR
161 161 Invalid character sequence is detected.
162 162 .SH ATTRIBUTES
163 163 .LP
164 164 See \fBattributes\fR(5) for descriptions of the following attributes:
165 165 .TS
166 166 box;
167 167 c | c
168 168 l | l .
169 169 ATTRIBUTE TYPE ATTRIBUTE VALUE
170 170 _
171 171 Interface Stability See below.
172 172 _
173 173 MT-Level See below.
174 174 .TE
175 175
176 176 .LP
177 177 The
178 178 .B mbrtowc()
179 179 function is Standard. The
180 180 .B mbrtowc_l()
181 181 function is Uncommitted.
182 182 .LP
183 183 If
184 184 .I ps
185 185 is a null pointer, these functions are Unsafe for use in
186 186 multithreaded applications. Otherwise they are MT-Safe.
187 187 .SH SEE ALSO
188 188 .LP
189 189 .BR mbsinit (3C),
190 190 .BR newlocale (3C),
191 191 .BR setlocale (3C),
192 192 .BR uselocale (3C),
193 193 .BR attributes (5),
194 194 .BR environ (5),
195 195 .BR standards (5)
↓ open down ↓ |
101 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX