Tag
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 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
<html>
<head>
<meta name="generator" content="groff -Thtml, see www.gnu.org">
<meta name="Content-Style" content="text/css">
<title>ICONV</title>
</head>
<body>
<h1 align=center>ICONV</h1>
<a href="#NAME">NAME</a><br>
<a href="#SYNOPSIS">SYNOPSIS</a><br>
<a href="#DESCRIPTION">DESCRIPTION</a><br>
<a href="#RETURN VALUE">RETURN VALUE</a><br>
<a href="#ERRORS">ERRORS</a><br>
<a href="#CONFORMING TO">CONFORMING TO</a><br>
<a href="#SEE ALSO">SEE ALSO</a><br>
<hr>
<!-- Creator : groff version 1.17 -->
<!-- CreationDate: Fri May 24 14:48:04 2002 -->
<a name="NAME"></a>
<h2>NAME</h2>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
iconv - perform character set conversion</td></table>
<a name="SYNOPSIS"></a>
<h2>SYNOPSIS</h2>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
<pre><b>#include <iconv.h>
size_t iconv (iconv_t</b> <i>cd</i><b>,
const char* *</b> <i>inbuf</i><b>, size_t *</b> <i>inbytesleft</i><b>,
char* *</b> <i>outbuf</i><b>, size_t *</b> <i>outbytesleft</i><b>);
</b></pre></td></table>
<a name="DESCRIPTION"></a>
<h2>DESCRIPTION</h2>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
The argument <i>cd</i> must be a conversion descriptor
created using the function <b>iconv_open</b>.</td></table>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
The main case is when <i>inbuf</i> is not NULL and
<i>*inbuf</i> is not NULL. In this case, the <b>iconv</b>
function converts the multibyte sequence starting at
<i>*inbuf</i> to a multibyte sequence starting at
<i>*outbuf</i>. At most <i>*inbytesleft</i> bytes, starting
at <i>*inbuf</i>, will be read. At most <i>*outbytesleft</i>
bytes, starting at <i>*outbuf</i>, will be
written.</td></table>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
The <b>iconv</b> function converts one multibyte character
at a time, and for each character conversion it increments
<i>*inbuf</i> and decrements <i>*inbytesleft</i> by the
number of converted input bytes, it increments
<i>*outbuf</i> and decrements <i>*outbytesptr</i> by the
number of converted output bytes, and it updates the
conversion state contained in <i>cd</i>. The conversion can
stop for four reasons:</td></table>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
1. An invalid multibyte sequence is encountered in the
input. In this case it sets <b>errno</b> to <b>EILSEQ</b>
and returns (size_t)(-1). <i>*inbuf</i> is left pointing to
the beginning of the invalid multibyte
sequence.</td></table>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
2. The input byte sequence has been entirely converted, i.e.
<i>*inbytesleft</i> has gone down to 0. In this case
<b>iconv</b> returns the number of non-reversible
conversions performed during this call.</td></table>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
3. An incomplete multibyte sequence is encountered in the
input, and the input byte sequence terminates after it. In
this case it sets <b>errno</b> to <b>EINVAL</b> and returns
(size_t)(-1). <i>*inbuf</i> is left pointing to the
beginning of the incomplete multibyte sequence.</td></table>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
4. The output buffer has no more room for the next converted
character. In this case it sets <b>errno</b> to <b>E2BIG</b>
and returns (size_t)(-1).</td></table>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
A different case is when <i>inbuf</i> is NULL or
<i>*inbuf</i> is NULL, but <i>outbuf</i> is not NULL and
<i>*outbuf</i> is not NULL. In this case, the <b>iconv</b>
function attempts to set <i>cd</i>'s conversion state to the
initial state and store a corresponding shift sequence at
<i>*outbuf</i>. At most <i>*outbytesleft</i> bytes, starting
at <i>*outbuf</i>, will be written. If the output buffer has
no more room for this reset sequence, it sets <b>errno</b>
to <b>E2BIG</b> and returns (size_t)(-1). Otherwise it
increments <i>*outbuf</i> and decrements <i>*outbytesptr</i>
by the number of bytes written.</td></table>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
A third case is when <i>inbuf</i> is NULL or <i>*inbuf</i>
is NULL, and <i>outbuf</i> is NULL or <i>*outbuf</i> is
NULL. In this case, the <b>iconv</b> function sets
<i>cd</i>'s conversion state to the initial
state.</td></table>
<a name="RETURN VALUE"></a>
<h2>RETURN VALUE</h2>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
The <b>iconv</b> function returns the number of characters
converted in a non-reversible way during this call;
reversible conversions are not counted. In case of error, it
sets <b>errno</b> and returns (iconv_t)(-1).</td></table>
<a name="ERRORS"></a>
<h2>ERRORS</h2>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
The following errors can occur, among others:</td></table>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
<b>E2BIG</b></td></table>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="21%"></td><td width="79%">
There is not sufficient room at <i>*outbuf</i>.</td></table>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
<b>EILSEQ</b></td></table>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="21%"></td><td width="79%">
An invalid multibyte sequence has been encountered in the
input.</td></table>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
<b>EINVAL</b></td></table>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="21%"></td><td width="79%">
An incomplete multibyte sequence has been encountered in the
input.</td></table>
<a name="CONFORMING TO"></a>
<h2>CONFORMING TO</h2>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
UNIX98</td></table>
<a name="SEE ALSO"></a>
<h2>SEE ALSO</h2>
<table width="100%" border=0 rules="none" frame="void"
cols="2" cellspacing="0" cellpadding="0">
<tr valign="top" align="left">
<td width="10%"></td><td width="90%">
<b>iconv_open</b>(3), <b>iconv_close</b>(3)</td></table>
<hr>
</body>
</html>