]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/iconv_open.3
Various pages: [GPL-2.0-or-later] Use SPDX-License-Identifier
[thirdparty/man-pages.git] / man3 / iconv_open.3
CommitLineData
fea681da
MK
1.\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
2.\"
e4a74ca8 3.\" SPDX-License-Identifier: GPL-2.0-or-later
fea681da
MK
4.\"
5.\" References consulted:
6.\" GNU glibc-2 source code and manual
008f1ecc 7.\" OpenGroup's Single UNIX specification
269e8424 8.\" http://www.UNIX-systems.org/online.html
fea681da 9.\"
988db661
MK
10.\" 2007-03-31 Bruno Haible, Describe the glibc/libiconv //TRANSLIT
11.\" and //IGNORE extensions for 'tocode'.
269e8424 12.\"
1d767b55 13.TH ICONV_OPEN 3 2021-03-22 "GNU" "Linux Programmer's Manual"
fea681da
MK
14.SH NAME
15iconv_open \- allocate descriptor for character set conversion
16.SH SYNOPSIS
17.nf
18.B #include <iconv.h>
68e4db0a 19.PP
fea681da
MK
20.BI "iconv_t iconv_open(const char *" tocode ", const char *" fromcode );
21.fi
22.SH DESCRIPTION
60a90ecd
MK
23The
24.BR iconv_open ()
25function allocates a conversion descriptor suitable
c6fa0841
MK
26for converting byte sequences from character encoding
27.I fromcode
28to
29character encoding
30.IR tocode .
fea681da 31.PP
c6fa0841 32The values permitted for
51700fd7 33.IR fromcode
c6fa0841
MK
34and
35.I tocode
36and the supported
a43eed0c 37combinations are system-dependent.
c13182ef 38For the GNU C library, the permitted
51700fd7 39values are listed by the
c6fa0841
MK
40.I "iconv \-\-list"
41command, and all combinations
fea681da 42of the listed values are supported.
269e8424
MK
43Furthermore the GNU C library and the
44GNU libiconv library support the following two suffixes:
45.TP
46//TRANSLIT
c6fa0841
MK
47When the string "//TRANSLIT" is appended to
48.IR tocode ,
49transliteration
269e8424
MK
50is activated.
51This means that when a character cannot be represented in the
52target character set, it can be approximated through one or several
53similarly looking characters.
54.TP
55//IGNORE
c6fa0841
MK
56When the string "//IGNORE" is appended to
57.IR tocode ,
58characters that
269e8424 59cannot be represented in the target character set will be silently discarded.
fea681da 60.PP
60a90ecd 61The resulting conversion descriptor can be used with
988db661 62.BR iconv (3)
269e8424 63any number of times.
60a90ecd 64It remains valid until deallocated using
3a72373c 65.BR iconv_close (3).
fea681da 66.PP
c13182ef
MK
67A conversion descriptor contains a conversion state.
68After creation using
60a90ecd
MK
69.BR iconv_open (),
70the state is in the initial state.
71Using
3a72373c 72.BR iconv (3)
c13182ef 73modifies the descriptor's conversion state.
60a90ecd 74To bring the state back to the initial state, use
3a72373c 75.BR iconv (3)
c6fa0841
MK
76with NULL as
77.I inbuf
78argument.
47297adb 79.SH RETURN VALUE
7a6227d3 80On success,
60a90ecd 81.BR iconv_open ()
7a6227d3 82returns a freshly allocated conversion
c13182ef 83descriptor.
7a6227d3
MK
84On failure, it returns
85.IR (iconv_t)\ \-1
86and sets
c6fa0841 87.I errno
7a6227d3 88to indicate the error.
fea681da
MK
89.SH ERRORS
90The following error can occur, among others:
91.TP
92.B EINVAL
c6fa0841 93The conversion from
51700fd7 94.IR fromcode
c6fa0841
MK
95to
96.I tocode
97is not supported by the
fea681da 98implementation.
3fd4929b
MK
99.SH VERSIONS
100This function is available in glibc since version 2.1.
9a8b397f
MS
101.SH ATTRIBUTES
102For an explanation of the terms used in this section, see
103.BR attributes (7).
c466875e
MK
104.ad l
105.nh
9a8b397f
MS
106.TS
107allbox;
c466875e 108lbx lb lb
9a8b397f
MS
109l l l.
110Interface Attribute Value
111T{
112.BR iconv_open ()
113T} Thread safety MT-Safe locale
114.TE
c466875e
MK
115.hy
116.ad
847e0d88 117.sp 1
47297adb 118.SH CONFORMING TO
6c90b6d4 119POSIX.1-2001, POSIX.1-2008, SUSv2.
47297adb 120.SH SEE ALSO
fea681da
MK
121.BR iconv (1),
122.BR iconv (3),
123.BR iconv_close (3)