1 .\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
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.
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
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
20 .\"WORD: conversion ÊÑ´¹
21 .\"WORD: descriptor ¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼
22 .\"WORD: sequence ʸ»úÎó
25 .TH ICONV 3 2008-09-08 "GNU" "Linux Programmer's Manual"
28 .\"O iconv \- perform character set conversion
29 iconv \- ʸ»ú¥»¥Ã¥ÈÊÑ´¹¤ò¹Ô¤¦
35 .BI "size_t iconv(iconv_t " cd ,
36 .BI " char **" inbuf ", size_t *" inbytesleft ,
37 .BI " char **" outbuf ", size_t *" outbytesleft );
41 .\"O The argument \fIcd\fP must be a conversion descriptor created using the
43 .\"O .BR iconv_open (3).
44 °ú¤¿ô \fIcd\fP ¤Ï¡¢´Ø¿ô
47 ÊÑ´¹¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
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
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.
57 ¡Ö\fIinbuf\fP ¤¬ NULL ¤Ç¤Ê¤¯¡¢¤«¤Ä \fI*inbuf\fP ¤¬ NULL ¤Ç¤Ê¤¤¡×
62 \fI*inbuf\fP ¤Ç»Ï¤Þ¤ë¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎó¤ò
63 \fI*outbuf\fP ¤Ç»Ï¤Þ¤ë¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎó¤ËÊÑ´¹¤¹¤ë¡£
64 \fI*inbuf\fP ¤òÀèƬ¤È¤·¤ÆºÇÂç \fI*inbytesleft\fP ¥Ð¥¤¥È¤¬Æɤ߹þ¤Þ¤ì¡¢
65 \fI*outbuf\fP ¤òÀèƬ¤È¤·¤ÆºÇÂç \fI*outbytesleft\fP ¥Ð¥¤¥È¤¬½ñ¤½Ð¤µ¤ì¤ë¡£
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
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:
81 ´Ø¿ô¤Ï 1 ÅÙ¤Ë 1 ¤Ä¤Î¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»ú¤òÊÑ´¹¤¹¤ë¡£
82 ¤½¤·¤Æ¡¢³Æʸ»úÊÑ´¹Ëè¤Ë¡¢ÊÑ´¹¤µ¤ì¤¿ÆþÎϥХ¤¥È¤Î¿ô¤À¤±
83 \fI*inbuf\fP ¤òÁý²Ã¤µ¤»¡¢\fI*inbytesleft\fP ¤ò¸º¾¯¤µ¤»¤ë¡£
84 ¤Þ¤¿¡¢ÊÑ´¹¤µ¤ì¤¿½ÐÎϥХ¤¥È¤Î¿ô¤À¤±
85 \fI*outbuf\fP ¤òÁý²Ã¤µ¤»¡¢\fI*outbytesleft\fP ¤ò¸º¾¯¤µ¤»¤ë¡£
86 ¤µ¤é¤Ë¡¢\fIcd\fP ¤Ë´Þ¤Þ¤ì¤ëÊÑ´¹¾õÂÖ¤ò¹¹¿·¤¹¤ë¡£
87 ÆþÎϤÎʸ»ú¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤¬¤¬¾õÂÖ¤ò»ý¤Ä¾ì¹ç¡¢
89 ´Ø¿ô¤ÏÆþÎϥХ¤¥È¤ÎÎó¤ËÂФ·¤ÆÊÑ´¹¤Ë¤âÂбþ¤·¤Æ¤ª¤ê¡¢
90 ¥Ð¥¤¥È½ÐÎϤòȼ¤ï¤º¤ËÊÑ´¹¾õÂÖ¤ò¹¹¿·¤¹¤ë¤³¤È¤¬¤Ç¤¤ë¡£
91 ÊÑ´¹¤Ï¡¢¼¡¤Î 4 ¤Ä¤Î¾ì¹ç¤ËÄä»ß¤¹¤ë¡£
93 .\"O 1. An invalid multibyte sequence is encountered in the input.
95 .\"O it sets \fIerrno\fP to \fBEILSEQ\fP and returns
96 .\"O .IR (size_t)\ \-1 .
98 .\"O is left pointing to the beginning of the invalid multibyte sequence.
99 1. ÆþÎϤË̵¸ú¤Ê¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎ󤬤¢¤Ã¤¿¾ì¹ç¡£
100 ¤³¤Î¾ì¹ç¡¢´Ø¿ô¤Ï \fIerrno\fP ¤ò \fBEILSEQ\fP ¤ËÀßÄꤷ¡¢
103 \fI*inbuf\fP ¤Ï¡¢Ìµ¸ú¤Ê¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎó¤ÎÀèƬ¤ò»Ø¤·¤¿¤Þ¤Þ¤Ë¤Ê¤ë¡£
105 .\"O 2. The input byte sequence has been entirely converted,
106 .\"O that is, \fI*inbytesleft\fP has gone down to 0.
109 .\"O returns the number of
110 .\"O nonreversible conversions performed during this call.
111 2. ÆþÎϥХ¤¥Èʸ»úÎ󤬴°Á´¤ËÊÑ´¹¤µ¤ì¡¢\fI*inbytesleft\fP ¤¬ 0 ¤Ë¤Ê¤Ã¤¿¾ì¹ç¡£
114 ¤Ï¡¢¸Æ½Ð¤·¤Î´Ö¤ËÈó²ÄµÕÊÑ´¹¤¬¹Ô¤ï¤ì¤¿²ó¿ô¤òÊÖ¤¹¡£
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 ¤ËÀßÄꤷ¡¢
128 \fI*inbuf\fP ¤Ï¡¢ÉÔ´°Á´¤Ê¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎó¤ÎÀèƬ¤ò»Ø¤·¤¿¤Þ¤Þ¤Ë¤µ¤ì¤ë¡£
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 ¤ËÀßÄꤵ¤ì¡¢
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
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
152 ¡Ö\fIinbuf\fP ¤¬ NULL¡¢¤Þ¤¿¤Ï \fI*inbuf\fP ¤¬ NULL ¤Ç¤¢¤ë¡£
153 ¤·¤«¤·¡¢\fIoutbuf\fP ¤¬ NULL ¤Ç¤Ê¤¯¡¢¤«¤Ä \fI*outbuf\fP ¤¬ NULL ¤Ç¤Ê¤¤¡×
157 ´Ø¿ô¤Ï¡¢\fIcd\fP ¤ÎÊÑ´¹¾õÂÖ¤ò½é´ü¾õÂ֤ˤ·¤Æ¡¢
158 Âбþ¤¹¤ë¥·¥Õ¥Èʸ»úÎó¤ò \fI*outbuf\fP ¤ËÊݸ¤·¤è¤¦¤È¤¹¤ë¡£
159 ºÇÂç \fI*outbytesleft\fP ¥Ð¥¤¥È¤¬¡¢\fI*outbuf\fP ¤ò»Ï¤á¤È¤·¤Æ½ñ¤½Ð¤µ¤ì¤ë¡£
160 ¤³¤Î¥ê¥»¥Ã¥È¤µ¤ì¤¿Ê¸»úÎó¤ËÂФ·¤Æ¡¢½ÐÎϥХåե¡¡¼¤Ë¶õ¤¤¬¤Ê¤¤¾ì¹ç¡¢
161 ¤³¤Î´Ø¿ô¤Ï \fIerrno\fP ¤ò \fBE2BIG\fP ¤ËÀßÄꤷ¡¢
164 ¤½¤ì°Ê³°¤Î¾ì¹ç¡¢¤³¤Î´Ø¿ô¤Ï¡¢½ñ¤¹þ¤Þ¤ì¤¿¥Ð¥¤¥È¤Î¿ô¤À¤±
165 \fI*outbuf\fP ¤òÁý²Ã¤µ¤»¡¢\fI*outbytesleft\fP ¤ò¸º¾¯¤µ¤»¤ë¡£
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
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 ¤Ç¤¢¤ë¡×
178 ´Ø¿ô¤Ï¡¢\fIcd\fP ¤ÎÊÑ´¹¾õÂÖ¤ò½é´ü¾õÂ֤ˤ¹¤ë¡£
179 .\"O .SH "RETURN VALUE"
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 .
188 ´Ø¿ô¤Ï¡¢¸Æ½Ð¤·¤Î´Ö¤ËÈó²ÄµÕ¤ÊÊýË¡¤ÇÊÑ´¹¤µ¤ì¤¿Ê¸»ú¿ô¤òÊÖ¤¹¡£
189 ¤Ä¤Þ¤ê¡¢²ÄµÕÊÑ´¹¤Ï¥«¥¦¥ó¥È¤µ¤ì¤Ê¤¤¡£
190 ¥¨¥é¡¼¤Î¾ì¹ç¡¢¤³¤Î´Ø¿ô¤Ï \fIerrno\fP ¤òÀßÄꤷ¡¢
195 .\"O The following errors can occur, among others:
196 ¾¤Î¤¤¤í¤¤¤í¤Ê¥¨¥é¡¼¤Î¤¦¤Á¤«¤é¡¢°Ê²¼¤Î¥¨¥é¡¼¤¬µ¯¤³¤ê¤¦¤ë¡£
199 .\"O There is not sufficient room at \fI*outbuf\fP.
200 \fI*outbuf\fP ¤Ë½½Ê¬¤Ê¶õ¤¤¬¤Ê¤¤¡£
203 .\"O An invalid multibyte sequence has been encountered in the input.
204 ÆþÎϤË̵¸ú¤Ê¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎ󤬤¢¤Ã¤¿¡£
207 .\"O An incomplete multibyte sequence has been encountered in the input.
208 ÆþÎϤËÉÔ´°Á´¤Ê¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎ󤬤¢¤Ã¤¿¡£
211 .\"O This function is available in glibc since version 2.1.
212 ¤³¤Î´Ø¿ô¤Ï¥Ð¡¼¥¸¥ç¥ó 2.1 °Ê¹ß¤Î glibc ¤ÇÍøÍѲÄǽ¤Ç¤¢¤ë¡£
213 .\"O .SH "CONFORMING TO"