iconv.3.html 6.7 KB

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