1 .\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
3 .\" This is free documentation; you can redistribute it and/or
4 .\" modify it under the terms of the GNU General Public License as
5 .\" published by the Free Software Foundation; either version 2 of
6 .\" the License, or (at your option) any later version.
8 .\" References consulted:
9 .\" GNU glibc-2 source code and manual
10 .\" OpenGroup's Single Unix specification
11 .\" http://www.UNIX-systems.org/online.html
13 .\" 2000-06-30 correction by Yuichi SATO <sato@complex.eng.hokudai.ac.jp>
14 .\" 2000-11-15 aeb, fixed prototype
16 .TH ICONV 3 2001-11-15 "GNU" "Linux Programmer's Manual"
18 iconv \- perform character set conversion
23 .BI "size_t iconv(iconv_t " cd ,
24 .BI " char **" inbuf ", size_t *" inbytesleft ,
25 .BI " char **" outbuf ", size_t *" outbytesleft );
28 The argument \fIcd\fP must be a conversion descriptor created using the
32 The main case is when \fIinbuf\fP is not NULL and \fI*inbuf\fP is not NULL.
35 function converts the multibyte sequence
36 starting at \fI*inbuf\fP to a multibyte sequence starting at \fI*outbuf\fP.
37 At most \fI*inbytesleft\fP bytes, starting at \fI*inbuf\fP, will be read.
38 At most \fI*outbytesleft\fP bytes, starting at \fI*outbuf\fP, will be written.
42 function converts one multibyte character at a time, and for
43 each character conversion it increments \fI*inbuf\fP and decrements
44 \fI*inbytesleft\fP by the number of converted input bytes, it increments
45 \fI*outbuf\fP and decrements \fI*outbytesleft\fP by the number of converted
46 output bytes, and it updates the conversion state contained in \fIcd\fP.
47 The conversion can stop for four reasons:
49 1. An invalid multibyte sequence is encountered in the input.
51 it sets \fIerrno\fP to \fBEILSEQ\fP and returns
54 is left pointing to the beginning of the invalid multibyte sequence.
56 2. The input byte sequence has been entirely converted,
57 that is, \fI*inbytesleft\fP has gone down to 0.
61 non-reversible conversions performed during this call.
63 3. An incomplete multibyte sequence is encountered in the input, and the
64 input byte sequence terminates after it.
65 In this case it sets \fIerrno\fP to
66 \fBEINVAL\fP and returns
68 \fI*inbuf\fP is left pointing to the
69 beginning of the incomplete multibyte sequence.
71 4. The output buffer has no more room for the next converted character.
72 In this case it sets \fIerrno\fP to \fBE2BIG\fP and returns
75 A different case is when \fIinbuf\fP is NULL or \fI*inbuf\fP is NULL, but
76 \fIoutbuf\fP is not NULL and \fI*outbuf\fP is not NULL.
79 function attempts to set \fIcd\fP's conversion state to the
80 initial state and store a corresponding shift sequence at \fI*outbuf\fP.
81 At most \fI*outbytesleft\fP bytes, starting at \fI*outbuf\fP, will be written.
82 If the output buffer has no more room for this reset sequence, it sets
83 \fIerrno\fP to \fBE2BIG\fP and returns
85 Otherwise it increments
86 \fI*outbuf\fP and decrements \fI*outbytesleft\fP by the number of bytes
89 A third case is when \fIinbuf\fP is NULL or \fI*inbuf\fP is NULL, and
90 \fIoutbuf\fP is NULL or \fI*outbuf\fP is NULL.
93 function sets \fIcd\fP's conversion state to the initial state.
97 function returns the number of characters converted in a
98 non-reversible way during this call; reversible conversions are not counted.
99 In case of error, it sets \fIerrno\fP and returns
102 The following errors can occur, among others:
105 There is not sufficient room at \fI*outbuf\fP.
108 An invalid multibyte sequence has been encountered in the input.
111 An incomplete multibyte sequence has been encountered in the input.