1 .\" $NetBSD: iconv.3,v 1.9 2004/01/24 15:33:43 wiz Exp $
3 .\" Copyright (c)2003 Citrus Project,
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
15 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" ----------------------------------------------------------------------
35 .Nd codeset conversion functions
36 .\" ----------------------------------------------------------------------
39 .\" ----------------------------------------------------------------------
43 .Fn iconv_open "const char *dstname" "const char *srcname"
45 .Fn iconv_close "iconv_t cd"
47 .Fn iconv "iconv_t cd" "const char ** restrict src" "size_t * restrict srcleft" "char ** restrict dst" "size_t * restrict dstleft"
48 .\" ----------------------------------------------------------------------
52 function opens a converter from the codeset
56 and returns its descriptor.
60 function closes the specified converter
65 function converts the string in the buffer
69 bytes and stores the converted string in the buffer
76 the values pointed to by
82 are updated as follows:
83 .Bl -tag -width 01234567
85 Pointer to the byte just after the last character fetched.
87 Number of remaining bytes in the source buffer.
89 Pointer to the byte just after the last character stored.
91 Number of remainder bytes in the destination buffer.
94 If the string pointed to by
96 contains a byte sequence which is not a valid character in the source
97 codeset, the conversion stops just after the last successful conversion.
98 If the output buffer is too small to store the converted
99 character, the conversion also stops in the same way.
100 In these cases, the values pointed to by
106 are updated to the state just after the last successful conversion.
108 If the string pointed to by
110 contains a character which is valid under the source codeset but
111 can not be converted to the destination codeset,
112 the character is replaced by an
113 .Dq invalid character
114 which depends on the destination codeset, e.g.,
116 and the conversion is continued.
118 returns the number of such
119 .Dq invalid conversions .
121 There are two special cases of
124 .It "src == NULL || *src == NULL"
126 If the source and/or destination codesets are stateful,
128 places these into their initial state.
135 .No non- Ns Dv NULL ,
137 stores the shift sequence for the destination switching to the initial state
138 in the buffer pointed to by
140 The buffer size is specified by the value pointed to by
144 will fail if the buffer is too small to store the shift sequence.
152 In this case, the shift sequence for the destination switching
153 to the initial state is discarded.
155 .\" ----------------------------------------------------------------------
157 Upon successful completion of
159 it returns a conversion descriptor.
162 returns (iconv_t)\-1 and sets errno to indicate the error.
164 Upon successful completion of
169 returns \-1 and sets errno to indicate the error.
171 Upon successful completion of
173 it returns the number of
178 returns (size_t)\-1 and sets errno to indicate the error.
179 .\" ----------------------------------------------------------------------
183 function may cause an error in the following cases:
188 There is no converter specified by
196 function may cause an error in the following case:
199 The conversion descriptor specified by
206 function may cause an error in the following cases:
209 The conversion descriptor specified by
213 The string pointed to by
215 contains a byte sequence which does not describe a valid character of
218 The output buffer pointed to by
220 is too small to store the result string.
222 The string pointed to by
224 terminates with an incomplete character or shift sequence.
226 .\" ----------------------------------------------------------------------
229 .\" ----------------------------------------------------------------------
237 .\" ----------------------------------------------------------------------
241 is aborted due to the occurrence of some error,
243 .Dq invalid conversion
244 count mentioned above is unfortunately lost.