OSDN Git Service

6f7bd4c9162a64e498f1395684591cc0a0ef3444
[linuxjm/LDP_man-pages.git] / draft / man3 / wcsrtombs.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 .\"   Dinkumware C library reference http://www.dinkumware.com/
11 .\"   OpenGroup's Single UNIX specification http://www.UNIX-systems.org/online.html
12 .\"   ISO/IEC 9899:1999
13 .\"
14 .\" About this Japanese page, please contact to JM Project <JM@linux.or.jp>
15 .\" Translated Sat Oct 23 15:38:11 JST 1999
16 .\"           by FUJIWARA Teruyoshi <fujiwara@linux.or.jp>
17 .\"
18 .TH WCSRTOMBS 3  2011-09-28 "GNU" "Linux Programmer's Manual"
19 .\"O .SH NAME
20 .SH 名前
21 .\"O wcsrtombs \- convert a wide-character string to a multibyte string
22 wcsrtombs \- ワイド文字文字列をマルチバイト文字列に変換する
23 .\"O .SH SYNOPSIS
24 .SH 書式
25 .nf
26 .B #include <wchar.h>
27 .sp
28 .BI "size_t wcsrtombs(char *" dest ", const wchar_t **" src ,
29 .BI "                 size_t " len ", mbstate_t *" ps );
30 .fi
31 .\"O .SH DESCRIPTION
32 .SH 説明
33 .\"O If \fIdest\fP is not a NULL pointer,
34 .\"O the
35 .\"O .BR wcsrtombs ()
36 .\"O function converts
37 .\"O the wide-character string \fI*src\fP to a multibyte string starting at
38 .\"O \fIdest\fP.
39 .\"O At most \fIlen\fP bytes are written to \fIdest\fP.
40 .\"O The shift state
41 .\"O \fI*ps\fP is updated.
42 .\"O The conversion is effectively performed by repeatedly
43 .\"O calling
44 .\"O .IR "wcrtomb(dest, *src, ps)" ,
45 .\"O as long as this call succeeds,
46 .\"O and then incrementing \fIdest\fP by the
47 .\"O number of bytes written and \fI*src\fP
48 .\"O by one.
49 .\"O The conversion can stop for three reasons:
50 \fIdest\fP が NULL ポインタでなければ、
51 .BR wcsrtombs ()
52 関数は
53 ワイド文字文字列 \fI*src\fP を \fIdest\fP が指すマルチバイト文字列
54 に変換する。最大 \fIlen\fP バイトまでが \fIdest\fP に書き込まれる。
55 シフト状態 \fI*ps\fP は更新される。実際の効果としては、この変換は以下
56 の動作と同じになる:
57 .IR "wcrtomb(dest, *src, ps)"
58 を呼び、成功が返ったら、
59 \fIdest\fP を書き込んだバイト数だけ増やし、\fI*src\fP を 1 増やす。
60 そして、wcrtomb が成功を返す限りこれを繰り返す。
61 変換が止まる理由は 3 つ考えられる:
62 .PP
63 .\"O 1. A wide character has been encountered that can not be represented as a
64 .\"O multibyte sequence (according to the current locale).
65 .\"O In this case \fI*src\fP
66 .\"O is left pointing to the invalid wide character,
67 .\"O .I (size_t)\ \-1
68 .\"O is returned,
69 .\"O and
70 .\"O .I errno
71 .\"O is set to \fBEILSEQ\fP.
72 (現在のロケールに基づいて)マルチバイト列で表現できないワイド文字に
73 出会った場合。この場合は、\fI*src\fP は不正なワイド文字を指した状態になり、
74 .I (size_t)\ \-1
75 が返され、
76 .I errno
77 に \fBEILSEQ\fP が設定される。
78 .PP
79 .\"O 2. The length limit forces a stop.
80 .\"O In this case \fI*src\fP is left pointing
81 .\"O to the next wide character to be converted,
82 .\"O and the number of bytes written to
83 .\"O \fIdest\fP is returned.
84 2. 長さの制限により変換が止められた場合。この場合には、\fI*src\fP は次に
85 変換されるべきワイド文字列を指した状態になり、\fIdest\fP に書き込まれ
86 たバイト数が返される。
87 .PP
88 .\"O 3. The wide-character string has been completely converted, including the
89 .\"O terminating null wide character (L\(aq\\0\(aq),
90 .\"O which has the side effect of bringing back \fI*ps\fP
91 .\"O to the initial state.
92 .\"O In this case \fI*src\fP is set to NULL, and the number
93 .\"O of bytes written to \fIdest\fP, excluding the terminating null, is returned.
94 3. ワイド文字列が終端の NULL ワイド文字 (L\(aq\\0\(aq) も含めて全て
95 変換された場合。この際、\fI*ps\fP が初期状態に戻るという副作用がある。
96 この場合には \fI*src\fP に NULL が設定され、\fIdest\fP に書き込まれた
97 バイト数が返される (終端の NULL は数えない)。
98 .PP
99 .\"O If \fIdest\fP is NULL, \fIlen\fP is ignored,
100 .\"O and the conversion proceeds as above, except that the converted bytes
101 .\"O are not written out to memory, and that
102 .\"O no length limit exists.
103 \fIdest\fP が NULL ならば \fIlen\fP は無視されて前述のように変換が行わ
104 れるが、変換されたバイトデータはメモリに書き出されない点と、出力先の長
105 さの制限がない点が異なる。
106 .PP
107 .\"O In both of the above cases,
108 .\"O if \fIps\fP is a NULL pointer, a static anonymous
109 .\"O state only known to the wcsrtombs function is used instead.
110 上記のいずれの場合も、\fIps\fP が NULL ポインタならば、wcsnrtombs 関数
111 だけが知っている静的な匿名の状態がシフト状態の代わりに用いられる。
112 .PP
113 .\"O The programmer must ensure that there is room for at least \fIlen\fP bytes
114 .\"O at \fIdest\fP.
115 プログラマは少なくとも \fIlen\fP バイトの領域を \fIdest\fP に確保しな
116 ければならない。
117 .\"O .SH "RETURN VALUE"
118 .SH 返り値
119 .\"O The
120 .\"O .BR wcsrtombs ()
121 .\"O function returns
122 .\"O the number of bytes that make up the
123 .\"O converted part of multibyte sequence,
124 .\"O not including the terminating null byte.
125 .BR wcsrtombs ()
126 は、変換して得られたマルチバイト列のバイト数を返す。
127 これには終端の null バイトは含まれない。
128 .\"O If a wide character was encountered
129 .\"O which could not be converted,
130 .\"O .I (size_t)\ \-1
131 .\"O is returned, and
132 .\"O .I errno
133 .\"O set to \fBEILSEQ\fP.
134 変換できないワイド文字に出会った場合には
135 .I (size_t)\ \-1
136 が返され、
137 .I errno
138 に \fBEILSEQ\fP が設定される。
139 .\"O .SH "CONFORMING TO"
140 .SH 準拠
141 C99.
142 .\"O .SH NOTES
143 .\"O The behavior of
144 .\"O .BR wcsrtombs ()
145 .\"O depends on the
146 .\"O .B LC_CTYPE
147 .\"O category of the
148 .\"O current locale.
149 .BR wcsrtombs ()
150 の動作は現在のロケールの
151 .B LC_CTYPE
152 カテゴリに依存する。
153 .PP
154 .\"O Passing NULL as \fIps\fP is not multithread safe.
155 \fIps\fP に NULL を渡した際の動作はマルチスレッドセーフでない。
156 .\"O .SH "SEE ALSO"
157 .SH 関連項目
158 .BR iconv (3),
159 .BR wcsnrtombs (3),
160 .BR wcstombs (3)