source: Daodan/MSYS2/usr/share/doc/iconv.3.html@ 1166

Last change on this file since 1166 was 1166, checked in by rossy, 3 years ago

Daodan: Replace MinGW build env with an up-to-date MSYS2 env

File size: 6.2 KB
Line 
1<!-- Creator : groff version 1.22.3 -->
2<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
3"http://www.w3.org/TR/html4/loose.dtd">
4<html>
5<head>
6<meta name="generator" content="groff -Thtml, see www.gnu.org">
7<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
8<meta name="Content-Style" content="text/css">
9<style type="text/css">
10 p { margin-top: 0; margin-bottom: 0; vertical-align: top }
11 pre { margin-top: 0; margin-bottom: 0; vertical-align: top }
12 table { margin-top: 0; margin-bottom: 0; vertical-align: top }
13 h1 { text-align: center }
14</style>
15<title>ICONV</title>
16
17</head>
18<body>
19
20<h1 align="center">ICONV</h1>
21
22<a href="#NAME">NAME</a><br>
23<a href="#SYNOPSIS">SYNOPSIS</a><br>
24<a href="#DESCRIPTION">DESCRIPTION</a><br>
25<a href="#RETURN VALUE">RETURN VALUE</a><br>
26<a href="#ERRORS">ERRORS</a><br>
27<a href="#CONFORMING TO">CONFORMING TO</a><br>
28<a href="#SEE ALSO">SEE ALSO</a><br>
29
30<hr>
31
32
33<h2>NAME
34<a name="NAME"></a>
35</h2>
36
37
38<p style="margin-left:11%; margin-top: 1em">iconv &minus;
39perform character set conversion</p>
40
41<h2>SYNOPSIS
42<a name="SYNOPSIS"></a>
43</h2>
44
45
46<p style="margin-left:11%; margin-top: 1em"><b>#include
47&lt;iconv.h&gt;</b></p>
48
49<p style="margin-left:11%; margin-top: 1em"><b>size_t iconv
50(iconv_t</b> <i>cd</i><b>, <br>
51const char* *</b> <i>inbuf</i><b>, size_t *</b>
52<i>inbytesleft</i><b>, <br>
53char* *</b> <i>outbuf</i><b>, size_t *</b>
54<i>outbytesleft</i><b>);</b></p>
55
56<h2>DESCRIPTION
57<a name="DESCRIPTION"></a>
58</h2>
59
60
61<p style="margin-left:11%; margin-top: 1em">The argument
62<i>cd</i> must be a conversion descriptor created using the
63function <b>iconv_open</b>.</p>
64
65<p style="margin-left:11%; margin-top: 1em">The main case
66is when <i>inbuf</i> is not NULL and <i>*inbuf</i> is not
67NULL. In this case, the <b>iconv</b> function converts the
68multibyte sequence starting at <i>*inbuf</i> to a multibyte
69sequence starting at <i>*outbuf</i>. At most
70<i>*inbytesleft</i> bytes, starting at <i>*inbuf</i>, will
71be read. At most <i>*outbytesleft</i> bytes, starting at
72<i>*outbuf</i>, will be written.</p>
73
74<p style="margin-left:11%; margin-top: 1em">The
75<b>iconv</b> function converts one multibyte character at a
76time, and for each character conversion it increments
77<i>*inbuf</i> and decrements <i>*inbytesleft</i> by the
78number of converted input bytes, it increments
79<i>*outbuf</i> and decrements <i>*outbytesleft</i> by the
80number of converted output bytes, and it updates the
81conversion state contained in <i>cd</i>. If the character
82encoding of the input is stateful, the <b>iconv</b> function
83can also convert a sequence of input bytes to an update of
84the conversion state without producing any output bytes;
85such input is called a <i>shift sequence</i>. The conversion
86can stop for four reasons:</p>
87
88<p style="margin-left:11%; margin-top: 1em">1. An invalid
89multibyte sequence is encountered in the input. In this case
90it sets <b>errno</b> to <b>EILSEQ</b> and returns
91(size_t)(&minus;1). <i>*inbuf</i> is left pointing to the
92beginning of the invalid multibyte sequence.</p>
93
94<p style="margin-left:11%; margin-top: 1em">2. The input
95byte sequence has been entirely converted, i.e.
96<i>*inbytesleft</i> has gone down to 0. In this case
97<b>iconv</b> returns the number of non-reversible
98conversions performed during this call.</p>
99
100<p style="margin-left:11%; margin-top: 1em">3. An
101incomplete multibyte sequence is encountered in the input,
102and the input byte sequence terminates after it. In this
103case it sets <b>errno</b> to <b>EINVAL</b> and returns
104(size_t)(&minus;1). <i>*inbuf</i> is left pointing to the
105beginning of the incomplete multibyte sequence.</p>
106
107<p style="margin-left:11%; margin-top: 1em">4. The output
108buffer has no more room for the next converted character. In
109this case it sets <b>errno</b> to <b>E2BIG</b> and returns
110(size_t)(&minus;1).</p>
111
112<p style="margin-left:11%; margin-top: 1em">A different
113case is when <i>inbuf</i> is NULL or <i>*inbuf</i> is NULL,
114but <i>outbuf</i> is not NULL and <i>*outbuf</i> is not
115NULL. In this case, the <b>iconv</b> function attempts to
116set <i>cd</i>&rsquo;s conversion state to the initial state
117and store a corresponding shift sequence at <i>*outbuf</i>.
118At most <i>*outbytesleft</i> bytes, starting at
119<i>*outbuf</i>, will be written. If the output buffer has no
120more room for this reset sequence, it sets <b>errno</b> to
121<b>E2BIG</b> and returns (size_t)(&minus;1). Otherwise it
122increments <i>*outbuf</i> and decrements
123<i>*outbytesleft</i> by the number of bytes written.</p>
124
125<p style="margin-left:11%; margin-top: 1em">A third case is
126when <i>inbuf</i> is NULL or <i>*inbuf</i> is NULL, and
127<i>outbuf</i> is NULL or <i>*outbuf</i> is NULL. In this
128case, the <b>iconv</b> function sets <i>cd</i>&rsquo;s
129conversion state to the initial state.</p>
130
131<h2>RETURN VALUE
132<a name="RETURN VALUE"></a>
133</h2>
134
135
136<p style="margin-left:11%; margin-top: 1em">The
137<b>iconv</b> function returns the number of characters
138converted in a non-reversible way during this call;
139reversible conversions are not counted. In case of error, it
140sets <b>errno</b> and returns (size_t)(&minus;1).</p>
141
142<h2>ERRORS
143<a name="ERRORS"></a>
144</h2>
145
146
147<p style="margin-left:11%; margin-top: 1em">The following
148errors can occur, among others:</p>
149
150<table width="100%" border="0" rules="none" frame="void"
151 cellspacing="0" cellpadding="0">
152<tr valign="top" align="left">
153<td width="11%"></td>
154<td width="9%">
155
156
157<p><b>E2BIG</b></p></td>
158<td width="2%"></td>
159<td width="78%">
160
161
162<p>There is not sufficient room at <i>*outbuf</i>.</p></td></tr>
163<tr valign="top" align="left">
164<td width="11%"></td>
165<td width="9%">
166
167
168<p><b>EILSEQ</b></p></td>
169<td width="2%"></td>
170<td width="78%">
171
172
173<p>An invalid multibyte sequence has been encountered in
174the input.</p></td></tr>
175<tr valign="top" align="left">
176<td width="11%"></td>
177<td width="9%">
178
179
180<p><b>EINVAL</b></p></td>
181<td width="2%"></td>
182<td width="78%">
183
184
185<p>An incomplete multibyte sequence has been encountered in
186the input.</p></td></tr>
187</table>
188
189<h2>CONFORMING TO
190<a name="CONFORMING TO"></a>
191</h2>
192
193
194<p style="margin-left:11%; margin-top: 1em">POSIX:2001</p>
195
196<h2>SEE ALSO
197<a name="SEE ALSO"></a>
198</h2>
199
200
201
202<p style="margin-left:11%; margin-top: 1em"><b>iconv_open</b>(3),
203<b>iconvctl</b>(3) <b>iconv_close</b>(3)</p>
204<hr>
205</body>
206</html>
Note: See TracBrowser for help on using the repository browser.