OSDN Git Service

(split) Import translated manuals from JM CVS Repository.
[linuxjm/LDP_man-pages.git] / draft / man3 / iconv.3
1 .\" Copyright (c) Bruno Haible <haible@clisp.cons.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
11 .\"     http://www.UNIX-systems.org/online.html
12 .\" 2000-06-30 correction by Yuichi SATO <sato@complex.eng.hokudai.ac.jp>
13 .\" 2000-11-15 aeb, fixed prototype
14 .\"
15 .\" Japanese Version Copyright (c) 2000 Yuichi SATO
16 .\"         all rights reserved.
17 .\" Translated 2000-07-11, Yuichi SATO <sato@complex.eng.hokudai.ac.jp>
18 .\" Updated 2008-09-14, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.09
19 .\"
20 .\"WORD:        conversion      ÊÑ´¹
21 .\"WORD:        descriptor      ¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼
22 .\"WORD:        sequence        Ê¸»úÎó
23 .\"WORD:        
24 .\"
25 .TH ICONV 3 2008-09-08 "GNU" "Linux Programmer's Manual"
26 .\"O .SH NAME
27 .SH Ì¾Á°
28 .\"O iconv \- perform character set conversion
29 iconv \- Ê¸»ú¥»¥Ã¥ÈÊÑ´¹¤ò¹Ô¤¦
30 .\"O .SH SYNOPSIS
31 .SH ½ñ¼°
32 .nf
33 .B #include <iconv.h>
34 .sp
35 .BI "size_t iconv(iconv_t " cd ,
36 .BI "             char **" inbuf ", size_t *" inbytesleft ,
37 .BI "             char **" outbuf ", size_t *" outbytesleft );
38 .fi
39 .\"O .SH DESCRIPTION
40 .SH ÀâÌÀ
41 .\"O The argument \fIcd\fP must be a conversion descriptor created using the
42 .\"O function
43 .\"O .BR iconv_open (3).
44 °ú¤­¿ô \fIcd\fP ¤Ï¡¢´Ø¿ô
45 .BR iconv_open (3)
46 ¤ò»È¤Ã¤ÆÀ¸À®¤µ¤ì¤ë
47 ÊÑ´¹¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
48 .PP
49 .\"O The main case is when \fIinbuf\fP is not NULL and \fI*inbuf\fP is not NULL.
50 .\"O In this case, the
51 .\"O .BR iconv ()
52 .\"O function converts the multibyte sequence
53 .\"O starting at \fI*inbuf\fP to a multibyte sequence starting at \fI*outbuf\fP.
54 .\"O At most \fI*inbytesleft\fP bytes, starting at \fI*inbuf\fP, will be read.
55 .\"O At most \fI*outbytesleft\fP bytes, starting at \fI*outbuf\fP, will be written.
56 ¼ç¤Ë»È¤ï¤ì¤ë¤Î¤Ï¡¢
57 ¡Ö\fIinbuf\fP ¤¬ NULL ¤Ç¤Ê¤¯¡¢¤«¤Ä \fI*inbuf\fP ¤¬ NULL ¤Ç¤Ê¤¤¡×
58 ¤È¤¤¤¦¾ì¹ç¤Ç¤¢¤ë¡£
59 ¤³¤Î¾ì¹ç¡¢
60 .BR iconv ()
61 ´Ø¿ô¤Ï¡¢
62 \fI*inbuf\fP ¤Ç»Ï¤Þ¤ë¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎó¤ò
63 \fI*outbuf\fP ¤Ç»Ï¤Þ¤ë¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎó¤ËÊÑ´¹¤¹¤ë¡£
64 \fI*inbuf\fP ¤òÀèƬ¤È¤·¤ÆºÇÂç \fI*inbytesleft\fP ¥Ð¥¤¥È¤¬Æɤ߹þ¤Þ¤ì¡¢
65 \fI*outbuf\fP ¤òÀèƬ¤È¤·¤ÆºÇÂç \fI*outbytesleft\fP ¥Ð¥¤¥È¤¬½ñ¤­½Ð¤µ¤ì¤ë¡£
66 .PP
67 .\"O The
68 .\"O .BR iconv ()
69 .\"O function converts one multibyte character at a time, and for
70 .\"O each character conversion it increments \fI*inbuf\fP and decrements
71 .\"O \fI*inbytesleft\fP by the number of converted input bytes, it increments
72 .\"O \fI*outbuf\fP and decrements \fI*outbytesptr\fP by the number of converted
73 .\"O output bytes, and it updates the conversion state contained in \fIcd\fP.
74 .\"O If the character encoding of the input is stateful, the
75 .\"O .BR iconv ()
76 .\"O function can also convert a sequence of input bytes
77 .\"O to an update to the conversion state without producing any output bytes;
78 .\"O such input is called a \fIshift sequence\fP.
79 .\"O The conversion can stop for four reasons:
80 .BR iconv ()
81 ´Ø¿ô¤Ï 1 Å٤ˠ1 ¤Ä¤Î¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»ú¤òÊÑ´¹¤¹¤ë¡£
82 ¤½¤·¤Æ¡¢³Æʸ»úÊÑ´¹Ëè¤Ë¡¢ÊÑ´¹¤µ¤ì¤¿ÆþÎϥХ¤¥È¤Î¿ô¤À¤±
83 \fI*inbuf\fP ¤òÁý²Ã¤µ¤»¡¢\fI*inbytesleft\fP ¤ò¸º¾¯¤µ¤»¤ë¡£
84 ¤Þ¤¿¡¢ÊÑ´¹¤µ¤ì¤¿½ÐÎϥХ¤¥È¤Î¿ô¤À¤±
85 \fI*outbuf\fP ¤òÁý²Ã¤µ¤»¡¢\fI*outbytesleft\fP ¤ò¸º¾¯¤µ¤»¤ë¡£
86 ¤µ¤é¤Ë¡¢\fIcd\fP ¤Ë´Þ¤Þ¤ì¤ëÊÑ´¹¾õÂÖ¤ò¹¹¿·¤¹¤ë¡£
87 ÆþÎϤÎʸ»ú¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤¬¤¬¾õÂÖ¤ò»ý¤Ä¾ì¹ç¡¢
88 .BR iconv ()
89 ´Ø¿ô¤ÏÆþÎϥХ¤¥È¤ÎÎó¤ËÂФ·¤ÆÊÑ´¹¤Ë¤âÂбþ¤·¤Æ¤ª¤ê¡¢
90 ¥Ð¥¤¥È½ÐÎϤòȼ¤ï¤º¤ËÊÑ´¹¾õÂÖ¤ò¹¹¿·¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
91 ÊÑ´¹¤Ï¡¢¼¡¤Î 4 ¤Ä¤Î¾ì¹ç¤ËÄä»ß¤¹¤ë¡£
92 .PP
93 .\"O 1. An invalid multibyte sequence is encountered in the input.
94 .\"O In this case
95 .\"O it sets \fIerrno\fP to \fBEILSEQ\fP and returns
96 .\"O .IR (size_t)\ \-1 .
97 .\"O \fI*inbuf\fP
98 .\"O is left pointing to the beginning of the invalid multibyte sequence.
99 1. ÆþÎϤË̵¸ú¤Ê¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎ󤬤¢¤Ã¤¿¾ì¹ç¡£
100 ¤³¤Î¾ì¹ç¡¢´Ø¿ô¤Ï \fIerrno\fP ¤ò \fBEILSEQ\fP ¤ËÀßÄꤷ¡¢
101 .I (size_t)\ \-1
102 ¤òÊÖ¤¹¡£
103 \fI*inbuf\fP ¤Ï¡¢Ìµ¸ú¤Ê¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎó¤ÎÀèƬ¤ò»Ø¤·¤¿¤Þ¤Þ¤Ë¤Ê¤ë¡£
104 .PP
105 .\"O 2. The input byte sequence has been entirely converted,
106 .\"O that is, \fI*inbytesleft\fP has gone down to 0.
107 .\"O In this case
108 .\"O .BR iconv ()
109 .\"O returns the number of
110 .\"O nonreversible conversions performed during this call.
111 2. ÆþÎϥХ¤¥Èʸ»úÎ󤬴°Á´¤ËÊÑ´¹¤µ¤ì¡¢\fI*inbytesleft\fP ¤¬ 0 ¤Ë¤Ê¤Ã¤¿¾ì¹ç¡£
112 ¤³¤Î¾ì¹ç¡¢
113 .BR iconv ()
114 ¤Ï¡¢¸Æ½Ð¤·¤Î´Ö¤ËÈó²ÄµÕÊÑ´¹¤¬¹Ô¤ï¤ì¤¿²ó¿ô¤òÊÖ¤¹¡£
115 .PP
116 .\"O 3. An incomplete multibyte sequence is encountered in the input, and the
117 .\"O input byte sequence terminates after it.
118 .\"O In this case it sets \fIerrno\fP to
119 .\"O \fBEINVAL\fP and returns
120 .\"O .IR (size_t)\ \-1 .
121 .\"O \fI*inbuf\fP is left pointing to the
122 .\"O beginning of the incomplete multibyte sequence.
123 3. ÆþÎϤËÉÔ´°Á´¤Ê¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎ󤬤¢¤ê¡¢
124 ÆþÎϥХ¤¥Èʸ»úÎ󤬤½¤Î¸å¤Ç½ªÎ»¤·¤Æ¤¤¤ë¾ì¹ç¡£
125 ¤³¤Î¾ì¹ç¡¢´Ø¿ô¤Ï¡¢\fIerrno\fP ¤ò \fBEINVAL\fP ¤ËÀßÄꤷ¡¢
126 .I (size_t)\ \-1
127 ¤òÊÖ¤¹¡£
128 \fI*inbuf\fP ¤Ï¡¢ÉÔ´°Á´¤Ê¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎó¤ÎÀèƬ¤ò»Ø¤·¤¿¤Þ¤Þ¤Ë¤µ¤ì¤ë¡£
129 .PP
130 .\"O 4. The output buffer has no more room for the next converted character.
131 .\"O In this case it sets \fIerrno\fP to \fBE2BIG\fP and returns
132 .\"O .IR (size_t)\ \-1 .
133 4. ½ÐÎϥХåե¡¡¼¤Ë¼¡¤ÎÊÑ´¹¤µ¤ì¤¿Ê¸»úÎó¤Î¤¿¤á¤Î¶õ¤­¤¬¤Ê¤¤¾ì¹ç¡£
134 ¤³¤Î¾ì¹ç¡¢\fIerrno\fP ¤¬ \fBE2BIG\fP ¤ËÀßÄꤵ¤ì¡¢
135 .I (size_t)\ \-1
136 ¤¬ÊÖ¤µ¤ì¤ë¡£
137 .PP
138 .\"O A different case is when \fIinbuf\fP is NULL or \fI*inbuf\fP is NULL, but
139 .\"O \fIoutbuf\fP is not NULL and \fI*outbuf\fP is not NULL.
140 .\"O In this case, the
141 .\"O .BR iconv ()
142 .\"O function attempts to set \fIcd\fP's conversion state to the
143 .\"O initial state and store a corresponding shift sequence at \fI*outbuf\fP.
144 .\"O At most \fI*outbytesleft\fP bytes, starting at \fI*outbuf\fP, will be written.
145 .\"O If the output buffer has no more room for this reset sequence, it sets
146 .\"O \fIerrno\fP to \fBE2BIG\fP and returns
147 .\"O .IR (size_t)\ \-1 .
148 .\"O Otherwise it increments
149 .\"O \fI*outbuf\fP and decrements \fI*outbytesptr\fP by the number of bytes
150 .\"O written.
151 Ê̤Υ±¡¼¥¹¤È¤·¤Æ¤Ï¡¢
152 ¡Ö\fIinbuf\fP ¤¬ NULL¡¢¤Þ¤¿¤Ï \fI*inbuf\fP ¤¬ NULL ¤Ç¤¢¤ë¡£
153 ¤·¤«¤·¡¢\fIoutbuf\fP ¤¬ NULL ¤Ç¤Ê¤¯¡¢¤«¤Ä \fI*outbuf\fP ¤¬ NULL ¤Ç¤Ê¤¤¡×
154 ¤È¤¤¤¦¾ì¹ç¤¬¤¢¤ë¡£
155 ¤³¤Î¾ì¹ç¡¢
156 .BR iconv ()
157 ´Ø¿ô¤Ï¡¢\fIcd\fP ¤ÎÊÑ´¹¾õÂÖ¤ò½é´ü¾õÂ֤ˤ·¤Æ¡¢
158 Âбþ¤¹¤ë¥·¥Õ¥Èʸ»úÎó¤ò \fI*outbuf\fP ¤ËÊݸ¤·¤è¤¦¤È¤¹¤ë¡£
159 ºÇÂç \fI*outbytesleft\fP ¥Ð¥¤¥È¤¬¡¢\fI*outbuf\fP ¤ò»Ï¤á¤È¤·¤Æ½ñ¤­½Ð¤µ¤ì¤ë¡£
160 ¤³¤Î¥ê¥»¥Ã¥È¤µ¤ì¤¿Ê¸»úÎó¤ËÂФ·¤Æ¡¢½ÐÎϥХåե¡¡¼¤Ë¶õ¤­¤¬¤Ê¤¤¾ì¹ç¡¢
161 ¤³¤Î´Ø¿ô¤Ï \fIerrno\fP ¤ò \fBE2BIG\fP ¤ËÀßÄꤷ¡¢
162 .I (size_t)\ \-1
163 ¤òÊÖ¤¹¡£
164 ¤½¤ì°Ê³°¤Î¾ì¹ç¡¢¤³¤Î´Ø¿ô¤Ï¡¢½ñ¤­¹þ¤Þ¤ì¤¿¥Ð¥¤¥È¤Î¿ô¤À¤±
165 \fI*outbuf\fP ¤òÁý²Ã¤µ¤»¡¢\fI*outbytesleft\fP ¤ò¸º¾¯¤µ¤»¤ë¡£
166 .PP
167 .\"O A third state is when \fIinbuf\fP is NULL or \fI*inbuf\fP is NULL, and
168 .\"O \fIoutbuf\fP is NULL or \fI*outbuf\fP is NULL.
169 .\"O In this case, the
170 .\"O .BR iconv ()
171 .\"O function sets \fIcd\fP's conversion state to the initial state.
172 3 ÈÖÌܤΥ±¡¼¥¹¤·¤Æ¤Ï¡¢
173 ¡Ö\fIinbuf\fP ¤¬ NULL¡¢¤Þ¤¿¤Ï \fI*inbuf\fP ¤¬ NULL ¤Ç¤¢¤ë¡£
174 ¤«¤Ä¡¢\fIoutbuf\fP ¤¬ NULL¡¢¤Þ¤¿¤Ï \fI*outbuf\fP ¤¬ NULL ¤Ç¤¢¤ë¡×
175 ¤È¤¤¤¦¾ì¹ç¤¬¤¢¤ë¡£
176 ¤³¤Î¾ì¹ç¡¢
177 .BR iconv ()
178 ´Ø¿ô¤Ï¡¢\fIcd\fP ¤ÎÊÑ´¹¾õÂÖ¤ò½é´ü¾õÂ֤ˤ¹¤ë¡£
179 .\"O .SH "RETURN VALUE"
180 .SH ÊÖ¤êÃÍ
181 .\"O The
182 .\"O .BR iconv ()
183 .\"O function returns the number of characters converted in a
184 .\"O nonreversible way during this call; reversible conversions are not counted.
185 .\"O In case of error, it sets \fIerrno\fP and returns
186 .\"O .IR (size_t)\ \-1 .
187 .BR iconv ()
188 ´Ø¿ô¤Ï¡¢¸Æ½Ð¤·¤Î´Ö¤ËÈó²ÄµÕ¤ÊÊýË¡¤ÇÊÑ´¹¤µ¤ì¤¿Ê¸»ú¿ô¤òÊÖ¤¹¡£
189 ¤Ä¤Þ¤ê¡¢²ÄµÕÊÑ´¹¤Ï¥«¥¦¥ó¥È¤µ¤ì¤Ê¤¤¡£
190 ¥¨¥é¡¼¤Î¾ì¹ç¡¢¤³¤Î´Ø¿ô¤Ï \fIerrno\fP ¤òÀßÄꤷ¡¢
191 .I (size_t)\ \-1
192 ¤òÊÖ¤¹¡£
193 .\"O .SH ERRORS
194 .SH ¥¨¥é¡¼
195 .\"O The following errors can occur, among others:
196 ¾¤Î¤¤¤í¤¤¤í¤Ê¥¨¥é¡¼¤Î¤¦¤Á¤«¤é¡¢°Ê²¼¤Î¥¨¥é¡¼¤¬µ¯¤³¤ê¤¦¤ë¡£
197 .TP
198 .B E2BIG
199 .\"O There is not sufficient room at \fI*outbuf\fP.
200 \fI*outbuf\fP ¤Ë½½Ê¬¤Ê¶õ¤­¤¬¤Ê¤¤¡£
201 .TP
202 .B EILSEQ
203 .\"O An invalid multibyte sequence has been encountered in the input.
204 ÆþÎϤË̵¸ú¤Ê¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎ󤬤¢¤Ã¤¿¡£
205 .TP
206 .B EINVAL
207 .\"O An incomplete multibyte sequence has been encountered in the input.
208 ÆþÎϤËÉÔ´°Á´¤Ê¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎ󤬤¢¤Ã¤¿¡£
209 .\"O .SH VERSIONS
210 .SH ¥Ð¡¼¥¸¥ç¥ó
211 .\"O This function is available in glibc since version 2.1.
212 ¤³¤Î´Ø¿ô¤Ï¥Ð¡¼¥¸¥ç¥ó 2.1 °Ê¹ß¤Î glibc ¤ÇÍøÍѲÄǽ¤Ç¤¢¤ë¡£
213 .\"O .SH "CONFORMING TO"
214 .SH ½àµò
215 POSIX.1-2001.
216 .\"O .SH "SEE ALSO"
217 .SH ´ØÏ¢¹àÌÜ
218 .BR iconv_close (3),
219 .BR iconv_open (3)