OSDN Git Service

0716c3eda59bc3f1f1c9f50dd8aee0abde115ad3
[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)