source: trunk/third/libiconv/man/iconv.3 @ 20454

Revision 20454, 3.9 KB checked in by ghudson, 21 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r20453, which included commits to RCS files with non-trunk default branches.
Line 
1.\" Copyright (c) Bruno Haible <bruno@clisp.org>
2.\"
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.
7.\"
8.\" References consulted:
9.\"   GNU glibc-2 source code and manual
10.\"   OpenGroup's Single Unix specification http://www.UNIX-systems.org/online.html
11.\"
12.TH ICONV 3  "January 21, 2004" "GNU" "Linux Programmer's Manual"
13.SH NAME
14iconv \- perform character set conversion
15.SH SYNOPSIS
16.nf
17.B #include <iconv.h>
18.sp
19.BI "size_t iconv (iconv_t " cd ,
20.BI "              const char* * " inbuf ", size_t * "inbytesleft ,
21.BI "              char* * " outbuf ", size_t * "outbytesleft );
22.fi
23.SH DESCRIPTION
24The argument \fIcd\fP must be a conversion descriptor created using the
25function \fBiconv_open\fP.
26.PP
27The main case is when \fIinbuf\fP is not NULL and \fI*inbuf\fP is not NULL.
28In this case, the \fBiconv\fP function converts the multibyte sequence
29starting at \fI*inbuf\fP to a multibyte sequence starting at \fI*outbuf\fP.
30At most \fI*inbytesleft\fP bytes, starting at \fI*inbuf\fP, will be read.
31At most \fI*outbytesleft\fP bytes, starting at \fI*outbuf\fP, will be written.
32.PP
33The \fBiconv\fP function converts one multibyte character at a time, and for
34each character conversion it increments \fI*inbuf\fP and decrements
35\fI*inbytesleft\fP by the number of converted input bytes, it increments
36\fI*outbuf\fP and decrements \fI*outbytesleft\fP by the number of converted
37output bytes, and it updates the conversion state contained in \fIcd\fP.
38The conversion can stop for four reasons:
39.PP
401. An invalid multibyte sequence is encountered in the input. In this case
41it sets \fBerrno\fP to \fBEILSEQ\fP and returns (size_t)(-1). \fI*inbuf\fP
42is left pointing to the beginning of the invalid multibyte sequence.
43.PP
442. The input byte sequence has been entirely converted, i.e. \fI*inbytesleft\fP
45has gone down to 0. In this case \fBiconv\fP returns the number of
46non-reversible conversions performed during this call.
47.PP
483. An incomplete multibyte sequence is encountered in the input, and the
49input byte sequence terminates after it. In this case it sets \fBerrno\fP to
50\fBEINVAL\fP and returns (size_t)(-1). \fI*inbuf\fP is left pointing to the
51beginning of the incomplete multibyte sequence.
52.PP
534. The output buffer has no more room for the next converted character. In
54this case it sets \fBerrno\fP to \fBE2BIG\fP and returns (size_t)(-1).
55.PP
56A different case is when \fIinbuf\fP is NULL or \fI*inbuf\fP is NULL, but
57\fIoutbuf\fP is not NULL and \fI*outbuf\fP is not NULL. In this case, the
58\fBiconv\fP function attempts to set \fIcd\fP's conversion state to the
59initial state and store a corresponding shift sequence at \fI*outbuf\fP.
60At most \fI*outbytesleft\fP bytes, starting at \fI*outbuf\fP, will be written.
61If the output buffer has no more room for this reset sequence, it sets
62\fBerrno\fP to \fBE2BIG\fP and returns (size_t)(-1). Otherwise it increments
63\fI*outbuf\fP and decrements \fI*outbytesleft\fP by the number of bytes
64written.
65.PP
66A third case is when \fIinbuf\fP is NULL or \fI*inbuf\fP is NULL, and
67\fIoutbuf\fP is NULL or \fI*outbuf\fP is NULL. In this case, the \fBiconv\fP
68function sets \fIcd\fP's conversion state to the initial state.
69.SH "RETURN VALUE"
70The \fBiconv\fP function returns the number of characters converted in a
71non-reversible way during this call; reversible conversions are not counted.
72In case of error, it sets \fBerrno\fP and returns (size_t)(-1).
73.SH ERRORS
74The following errors can occur, among others:
75.TP
76.B E2BIG
77There is not sufficient room at \fI*outbuf\fP.
78.TP
79.B EILSEQ
80An invalid multibyte sequence has been encountered in the input.
81.TP
82.B EINVAL
83An incomplete multibyte sequence has been encountered in the input.
84.SH "CONFORMING TO"
85UNIX98
86.SH "SEE ALSO"
87.BR iconv_open "(3), " iconv_close (3)
Note: See TracBrowser for help on using the repository browser.