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 ディスクリプター
25 .TH ICONV 3 2008-09-08 "GNU" "Linux Programmer's Manual"
28 .\"O iconv \- perform character set conversion
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).
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 を減少させる。
85 \fI*outbuf\fP を増加させ、\fI*outbytesleft\fP を減少させる。
86 さらに、\fIcd\fP に含まれる変換状態を更新する。
87 入力の文字エンコーディングがが状態を持つ場合、
89 関数は入力バイトの列に対して変換にも対応しており、
90 バイト出力を伴わずに変換状態を更新することができる。
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.
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 関数は、呼出しの間に非可逆な方法で変換された文字数を返す。
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.
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"