]>
Commit | Line | Data |
---|---|---|
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 |
15 | iconv_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 |
23 | The |
24 | .BR iconv_open () | |
25 | function allocates a conversion descriptor suitable | |
c6fa0841 MK |
26 | for converting byte sequences from character encoding |
27 | .I fromcode | |
28 | to | |
29 | character encoding | |
30 | .IR tocode . | |
fea681da | 31 | .PP |
c6fa0841 | 32 | The values permitted for |
51700fd7 | 33 | .IR fromcode |
c6fa0841 MK |
34 | and |
35 | .I tocode | |
36 | and the supported | |
a43eed0c | 37 | combinations are system-dependent. |
c13182ef | 38 | For the GNU C library, the permitted |
51700fd7 | 39 | values are listed by the |
c6fa0841 MK |
40 | .I "iconv \-\-list" |
41 | command, and all combinations | |
fea681da | 42 | of the listed values are supported. |
269e8424 MK |
43 | Furthermore the GNU C library and the |
44 | GNU libiconv library support the following two suffixes: | |
45 | .TP | |
46 | //TRANSLIT | |
c6fa0841 MK |
47 | When the string "//TRANSLIT" is appended to |
48 | .IR tocode , | |
49 | transliteration | |
269e8424 MK |
50 | is activated. |
51 | This means that when a character cannot be represented in the | |
52 | target character set, it can be approximated through one or several | |
53 | similarly looking characters. | |
54 | .TP | |
55 | //IGNORE | |
c6fa0841 MK |
56 | When the string "//IGNORE" is appended to |
57 | .IR tocode , | |
58 | characters that | |
269e8424 | 59 | cannot be represented in the target character set will be silently discarded. |
fea681da | 60 | .PP |
60a90ecd | 61 | The resulting conversion descriptor can be used with |
988db661 | 62 | .BR iconv (3) |
269e8424 | 63 | any number of times. |
60a90ecd | 64 | It remains valid until deallocated using |
3a72373c | 65 | .BR iconv_close (3). |
fea681da | 66 | .PP |
c13182ef MK |
67 | A conversion descriptor contains a conversion state. |
68 | After creation using | |
60a90ecd MK |
69 | .BR iconv_open (), |
70 | the state is in the initial state. | |
71 | Using | |
3a72373c | 72 | .BR iconv (3) |
c13182ef | 73 | modifies the descriptor's conversion state. |
60a90ecd | 74 | To bring the state back to the initial state, use |
3a72373c | 75 | .BR iconv (3) |
c6fa0841 MK |
76 | with NULL as |
77 | .I inbuf | |
78 | argument. | |
47297adb | 79 | .SH RETURN VALUE |
7a6227d3 | 80 | On success, |
60a90ecd | 81 | .BR iconv_open () |
7a6227d3 | 82 | returns a freshly allocated conversion |
c13182ef | 83 | descriptor. |
7a6227d3 MK |
84 | On failure, it returns |
85 | .IR (iconv_t)\ \-1 | |
86 | and sets | |
c6fa0841 | 87 | .I errno |
7a6227d3 | 88 | to indicate the error. |
fea681da MK |
89 | .SH ERRORS |
90 | The following error can occur, among others: | |
91 | .TP | |
92 | .B EINVAL | |
c6fa0841 | 93 | The conversion from |
51700fd7 | 94 | .IR fromcode |
c6fa0841 MK |
95 | to |
96 | .I tocode | |
97 | is not supported by the | |
fea681da | 98 | implementation. |
3fd4929b MK |
99 | .SH VERSIONS |
100 | This function is available in glibc since version 2.1. | |
9a8b397f MS |
101 | .SH ATTRIBUTES |
102 | For 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 |
107 | allbox; | |
c466875e | 108 | lbx lb lb |
9a8b397f MS |
109 | l l l. |
110 | Interface Attribute Value | |
111 | T{ | |
112 | .BR iconv_open () | |
113 | T} Thread safety MT-Safe locale | |
114 | .TE | |
c466875e MK |
115 | .hy |
116 | .ad | |
847e0d88 | 117 | .sp 1 |
47297adb | 118 | .SH CONFORMING TO |
6c90b6d4 | 119 | POSIX.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) |