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 .\" Dinkumware C library reference http://www.dinkumware.com/
11 .\" OpenGroup's Single UNIX specification
12 .\" http://www.UNIX-systems.org/online.html
15 .\" Japanese Version Copyright (c) 1999 HANATAKA Shinya
16 .\" all rights reserved.
17 .\" Translated Tue Jan 11 00:56:16 JST 2000
18 .\" by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
19 .\" Updated Thu Dec 13 JST 2001 by Kentaro Shirakata <argrath@ub32.org>
21 .TH MBRTOWC 3 2011-09-28 "GNU" "Linux Programmer's Manual"
24 .\"O mbrtowc \- convert a multibyte sequence to a wide character
25 mbrtowc \- マルチバイト列をワイド文字に変換する
31 .BI "size_t mbrtowc(wchar_t *" pwc ", const char *" s ", size_t " n \
36 .\"O The main case for this function is when \fIs\fP is not NULL and \fIpwc\fP is
38 .\"O In this case, the
40 .\"O function inspects at most \fIn\fP
41 .\"O bytes of the multibyte string starting at \fIs\fP, extracts the next complete
42 .\"O multibyte character, converts it to a wide character and stores it at
44 .\"O It updates the shift state \fI*ps\fP.
45 .\"O If the converted wide
46 .\"O- character is not L\(aq\\0\(aq, it returns the number of bytes that were consumed
47 .\"O+ character is not L\(aq\\0\(aq (the null wide character),
48 .\"O+ it returns the number of bytes that were consumed
50 .\"O If the converted wide character is L\(aq\\0\(aq, it resets the shift
51 .\"O state \fI*ps\fP to the initial state and returns 0.
52 この関数が用いられる場合、通常 \fIs\fP が NULL でなく \fIpwc\fP も NULL で
55 関数は \fIs\fP から始まる最大 \fIn\fP バイトの
56 マルチバイト文字を検査して、次の完全なマルチバイト文字列を取り出し、
57 それをワイド文字に変換して \fI*pwc\fP に格納する。
58 同時にシフト状態 \fI*ps\fP を更新する。
59 変換したワイド文字が L\(aq\\0\(aq (NULL ワイド文字) でなければ、
60 \fIs\fP から消費するバイト数を返す。
61 変換したワイド文字が L\(aq\\0\(aq の場合にはシフト状態 \fI*ps\fP を
64 .\"O If the \fIn\fP bytes starting at \fIs\fP do not contain a complete multibyte
67 .\"O returns \fI(size_t)\ \-2\fP.
68 .\"O This can happen even if
69 .\"O \fIn\fP >= \fIMB_CUR_MAX\fP, if the multibyte string contains redundant shift
71 \fIs\fP から始まる \fIn\fP バイトが完全なマルチバイト文字を含んでいない
74 は \fI(size_t)\ \-2\fP を返す。
75 マルチバイト文字列に冗長なシフトシーケンスが含まれていると、
76 \fIn\fP >= \fIMB_CUR_MAX\fP の時にもこのようなことが起こりえる。
78 .\"O If the multibyte string starting at \fIs\fP contains an invalid multibyte
79 .\"O sequence before the next complete character,
82 .\"O \fI(size_t)\ \-1\fP and sets \fIerrno\fP to \fBEILSEQ\fP.
84 .\"O the effects on \fI*ps\fP are undefined.
85 \fIs\fP から始まるマルチバイト文字列が、次の完全な文字の前に
89 \fI(size_t)\ \-1\fP を返し、\fIerrno\fP に \fBEILSEQ\fP を設定する。
90 この場合は \fI*ps\fP への影響は未定義である。
92 .\"O A different case is when \fIs\fP is not NULL but \fIpwc\fP is NULL.
96 .\"O function behaves as above, except that it does not
97 .\"O store the converted wide character in memory.
98 \fIs\fP が NULL でなく \fIpwc\fP が NULL の場合は
101 上記と同様に動作するが、変換したワイド文字はメモリには書き込まれない。
103 .\"O A third case is when \fIs\fP is NULL.
104 .\"O In this case, \fIpwc\fP and \fIn\fP are
106 .\"O If the conversion state represented by \fI*ps\fP denotes an
107 .\"O incomplete multibyte character conversion, the
110 .\"O returns \fI(size_t)\ \-1\fP, sets \fIerrno\fP to \fBEILSEQ\fP, and
111 .\"O leaves \fI*ps\fP in an undefined state.
115 puts \fI*ps\fP in the initial state and returns 0.
116 三番目の場合として \fIs\fP が NULL の場合、 \fIpwc\fP と \fIn\fP は
118 \fI*ps\fP が表現する変換状態が不完全なマルチバイト文字変換を示している場合は、
120 関数は \fI(size_t)\ \-1\fP を返し、
121 \fIerrno\fP に \fBEILSEQ\fP をセットし、
122 \fI*ps\fP は未定義状態のままにする。
125 関数は \fI*ps\fP を初期状態にして 0 を返す。
127 .\"O In all of the above cases, if \fIps\fP is a NULL pointer, a static anonymous
128 .\"O state only known to the mbrtowc function is used instead.
129 上記の全ての場合において、\fIps\fP が NULL ポインターならば代わりに
130 mbrtowc 関数のみが使用する静的で名前のない状態が使用される。
131 .\"O Otherwise, \fI*ps\fP must be a valid \fImbstate_t\fP object.
132 さもなければ、\fI*ps\fP は有効な \fImbstate_t\fP オブジェクトで
134 .\"O An \fImbstate_t\fP object \fIa\fP can be initialized to the initial state
135 .\"O by zeroing it, for example using
136 \fImbstate_t\fP オブジェクトである \fIa\fP はゼロで埋めることによって
140 memset(&a, 0, sizeof(a));
142 .\"O .SH "RETURN VALUE"
146 .\"O function returns the number of bytes parsed from the
147 .\"O multibyte sequence starting at \fIs\fP, if a non-L\(aq\\0\(aq wide character
149 L\(aq\\0\(aq 以外のワイド文字を認識した場合には
152 から始まるマルチバイト列から解析したバイト数を返す。
153 .\"O It returns 0, if a L\(aq\\0\(aq wide character was recognized.
155 .\"O .I (size_t)\ \-1
156 .\"O and sets \fIerrno\fP to \fBEILSEQ\fP, if an invalid multibyte sequence was
158 .\"O It returns \fI(size_t)\ \-2\fP if it couldn't parse a complete multibyte
159 .\"O character, meaning that \fIn\fP should be increased.
160 L\(aq\\0\(aq ワイド文字を認識した場合には 0 を返す。
164 \fIerrno\fP に \fBEILSEQ\fP を設定する。完全なマルチバイト文字を
167 を返し \fIn\fP を増加させる必要があることを示す。
168 .\"O .SH "CONFORMING TO"