OSDN Git Service

(split) Import translated manuals from JM CVS Repository.
[linuxjm/LDP_man-pages.git] / draft / man3 / mbrtowc.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
12 .\"      http://www.UNIX-systems.org/online.html
13 .\"   ISO/IEC 9899:1999
14 .\"
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>
20 .\"
21 .TH MBRTOWC 3  2001-11-22 "GNU" "Linux Programmer's Manual"
22 .\"O .SH NAME
23 .SH Ì¾Á°
24 .\"O mbrtowc \- convert a multibyte sequence to a wide character
25 mbrtowc \- ¥Þ¥ë¥Á¥Ð¥¤¥ÈÎó¤ò¥ï¥¤¥Éʸ»ú¤ËÊÑ´¹¤¹¤ë
26 .\"O .SH SYNOPSIS
27 .SH ½ñ¼°
28 .nf
29 .B #include <wchar.h>
30 .sp
31 .BI "size_t mbrtowc(wchar_t *" pwc ", const char *" s ", size_t " n \
32 ", mbstate_t *" ps );
33 .fi
34 .\"O .SH DESCRIPTION
35 .SH ÀâÌÀ
36 .\"O The main case for this function is when \fIs\fP is not NULL and \fIpwc\fP is
37 .\"O not NULL.
38 .\"O In this case, the
39 .\"O .BR mbrtowc ()
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
43 .\"O \fI*pwc\fP.
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 from \fIs\fP.
48 .\"O If the converted wide character is L\(aq\\0\(aq, it resets the shift
49 .\"O state \fI*ps\fP to the initial state and returns 0.
50 ¤³¤Î´Ø¿ô¤¬ÍѤ¤¤é¤ì¤ë¾ì¹ç¡¢Ä̾ï \fIs\fP ¤¬ NULL ¤Ç¤Ê¤¯ \fIpwc\fP ¤â NULL ¤Ç
51 ¤Ê¤¤¡£¤³¤Î¾ì¹ç¤Ï¡¢
52 .BR mbrtowc ()
53 ´Ø¿ô¤Ï \fIs\fP ¤«¤é»Ï¤Þ¤ëºÇÂç \fIn\fP ¥Ð¥¤¥È¤Î
54 ¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»ú¤ò¸¡ºº¤·¤Æ¡¢¼¡¤Î´°Á´¤Ê¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎó¤ò¼è¤ê½Ð¤·¡¢
55 ¤½¤ì¤ò¥ï¥¤¥Éʸ»ú¤ËÊÑ´¹¤·¤Æ \fI*pwc\fP ¤Ë³ÊǼ¤¹¤ë¡£
56 Ʊ»þ¤Ë¥·¥Õ¥È¾õÂÖ \fI*ps\fP ¤ò¹¹¿·¤¹¤ë¡£ÊÑ´¹¤·¤¿¥ï¥¤¥Éʸ»ú¤¬ L\(aq\\0\(aq ¤Ç
57 ¤Ê¤±¤ì¤Ð¡¢\fIs\fP ¤«¤é¾ÃÈñ¤¹¤ë¥Ð¥¤¥È¿ô¤òÊÖ¤¹¡£
58 ÊÑ´¹¤·¤¿¥ï¥¤¥Éʸ»ú¤¬ L\(aq\\0\(aq ¤Î¾ì¹ç¤Ë¤Ï¥·¥Õ¥È¾õÂÖ \fI*ps\fP ¤ò
59 ½é´ü¾õÂÖ¤ËÌᤷ¤Æ 0 ¤òÊÖ¤¹¡£
60 .PP
61 .\"O If the \fIn\fP bytes starting at \fIs\fP do not contain a complete multibyte
62 .\"O character,
63 .\"O .BR mbrtowc ()
64 .\"O returns \fI(size_t)\ \-2\fP.
65 .\"O This can happen even if
66 .\"O \fIn\fP >= \fIMB_CUR_MAX\fP, if the multibyte string contains redundant shift
67 .\"O sequences.
68 \fIs\fP ¤«¤é»Ï¤Þ¤ë \fIn\fP ¥Ð¥¤¥È¤¬´°Á´¤Ê¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»ú¤ò´Þ¤ó¤Ç¤¤¤Ê¤¤
69 ¾ì¹ç¤Ë¤Ï¡¢
70 .BR mbrtowc ()
71 ¤Ï \fI(size_t)\ \-2\fP ¤òÊÖ¤¹¡£
72 ¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎó¤Ë¾éĹ¤Ê¥·¥Õ¥È¥·¡¼¥±¥ó¥¹¤¬´Þ¤Þ¤ì¤Æ¤¤¤ë¤È¡¢
73 \fIn\fP >= \fIMB_CUR_MAX\fP ¤Î»þ¤Ë¤â¤³¤Î¤è¤¦¤Ê¤³¤È¤¬µ¯¤³¤ê¤¨¤ë¡£
74 .PP
75 .\"O If the multibyte string starting at \fIs\fP contains an invalid multibyte
76 .\"O sequence before the next complete character,
77 .\"O .BR mbrtowc ()
78 .\"O returns
79 .\"O \fI(size_t)\ \-1\fP and sets \fIerrno\fP to \fBEILSEQ\fP.
80 .\"O In this case,
81 .\"O the effects on \fI*ps\fP are undefined.
82 \fIs\fP ¤«¤é»Ï¤Þ¤ë¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎ󤬡¢¼¡¤Î´°Á´¤Êʸ»ú¤ÎÁ°¤Ë
83 ÉÔÀµ¤Ê¥Þ¥ë¥Á¥Ð¥¤¥ÈÎó¤ò´Þ¤ó¤Ç¤¤¤ë¾ì¹ç¤Ë¤Ï¡¢
84 .BR mbrtowc ()
85 ¤Ï
86 \fI(size_t)\ \-1\fP ¤òÊÖ¤·¡¢\fIerrno\fP ¤Ë \fBEILSEQ\fP ¤òÀßÄꤹ¤ë¡£
87 ¤³¤Î¾ì¹ç¤Ï \fI*ps\fP ¤Ø¤Î±Æ¶Á¤Ï̤ÄêµÁ¤Ç¤¢¤ë¡£
88 .PP
89 .\"O A different case is when \fIs\fP is not NULL but \fIpwc\fP is NULL.
90 .\"O In this
91 .\"O case the
92 .\"O .BR mbrtowc ()
93 .\"O function behaves as above, except that it does not
94 .\"O store the converted wide character in memory.
95 \fIs\fP ¤¬ NULL ¤Ç¤Ê¤¯ \fIpwc\fP ¤¬ NULL ¤Î¾ì¹ç¤Ï
96 .BR mbrtowc ()
97 ´Ø¿ô¤Ï
98 ¾åµ­¤ÈƱÍͤËÆ°ºî¤¹¤ë¤¬¡¢ÊÑ´¹¤·¤¿¥ï¥¤¥Éʸ»ú¤Ï¥á¥â¥ê¤Ë¤Ï½ñ¤­¹þ¤Þ¤ì¤Ê¤¤¡£
99 .PP
100 .\"O A third case is when \fIs\fP is NULL.
101 .\"O In this case, \fIpwc\fP and \fIn\fP are
102 .\"O ignored.
103 .\"O If the conversion state represented by \fI*ps\fP denotes an
104 .\"O incomplete multibyte character conversion, the
105 .\"O .BR mbrtowc ()
106 .\"O function
107 .\"O returns \fI(size_t)\ \-1\fP, sets \fIerrno\fP to \fBEILSEQ\fP, and
108 .\"O leaves \fI*ps\fP in an undefined state.
109 .\"O Otherwise, the
110 .\"O .BR mbrtowc ()
111 .\"O function
112 puts \fI*ps\fP in the initial state and returns 0.
113 »°ÈÖÌܤξì¹ç¤È¤·¤Æ \fIs\fP ¤¬ NULL ¤Î¾ì¹ç¡¢ \fIpwc\fP ¤È \fIn\fP ¤Ï
114 ̵»ë¤µ¤ì¤ë¡£
115 \fI*ps\fP ¤¬É½¸½¤¹¤ëÊÑ´¹¾õÂÖ¤¬ÉÔ´°Á´¤Ê¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÊÑ´¹¤ò¼¨¤·¤Æ¤¤¤ë¾ì¹ç¤Ï¡¢
116 .BR mbrtowc ()
117 ´Ø¿ô¤Ï \fI(size_t)\ \-1\fP ¤òÊÖ¤·¡¢
118 \fIerrno\fP ¤Ë \fBEILSEQ\fP ¤ò¥»¥Ã¥È¤·¡¢
119 \fI*ps\fP ¤Ï̤ÄêµÁ¾õÂ֤Τޤޤˤ¹¤ë¡£
120 ¤µ¤â¤Ê¤±¤ì¤Ð¡¢
121 .BR mbrtowc ()
122 ´Ø¿ô¤Ï \fI*ps\fP ¤ò½é´ü¾õÂ֤ˤ·¤Æ 0 ¤òÊÖ¤¹¡£
123 .PP
124 .\"O In all of the above cases, if \fIps\fP is a NULL pointer, a static anonymous
125 .\"O state only known to the mbrtowc function is used instead.
126 ¾åµ­¤ÎÁ´¤Æ¤Î¾ì¹ç¤Ë¤ª¤¤¤Æ¡¢\fIps\fP ¤¬ NULL ¥Ý¥¤¥ó¥¿¡¼¤Ê¤é¤ÐÂå¤ï¤ê¤Ë
127 mbrtowc ´Ø¿ô¤Î¤ß¤¬»ÈÍѤ¹¤ëÀÅŪ¤Ç̾Á°¤Î¤Ê¤¤¾õÂÖ¤¬»ÈÍѤµ¤ì¤ë¡£
128 .\"O Otherwise, \fI*ps\fP must be a valid \fImbstate_t\fP object.
129 ¤µ¤â¤Ê¤±¤ì¤Ð¡¢\fI*ps\fP ¤ÏÍ­¸ú¤Ê \fImbstate_t\fP ¥ª¥Ö¥¸¥§¥¯¥È¤Ç
130 ¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
131 .\"O An \fImbstate_t\fP object \fIa\fP can be initialized to the initial state
132 .\"O by zeroing it, for example using
133 \fImbstate_t\fP ¥ª¥Ö¥¸¥§¥¯¥È¤Ç¤¢¤ë \fIa\fP ¤Ï¥¼¥í¤ÇËä¤á¤ë¤³¤È¤Ë¤è¤Ã¤Æ
134 ½é´ü¾õÂ֤˽é´ü²½¤Ç¤­¤ë¡£°Ê²¼¤ËÎã¤ò¼¨¤¹¡£
135 .sp
136 .in +4n
137 memset(&a, 0, sizeof(a));
138 .in
139 .\"O .SH "RETURN VALUE"
140 .SH ÊÖ¤êÃÍ
141 .\"O The
142 .\"O .BR mbrtowc ()
143 .\"O function returns the number of bytes parsed from the
144 .\"O multibyte sequence starting at \fIs\fP, if a non-L\(aq\\0\(aq wide character
145 .\"O was recognized.
146 L\(aq\\0\(aq °Ê³°¤Î¥ï¥¤¥Éʸ»ú¤òǧ¼±¤·¤¿¾ì¹ç¤Ë¤Ï
147 .BR mbrtowc ()
148 ´Ø¿ô¤Ï \fIs\fP
149 ¤«¤é»Ï¤Þ¤ë¥Þ¥ë¥Á¥Ð¥¤¥ÈÎ󤫤é²òÀϤ·¤¿¥Ð¥¤¥È¿ô¤òÊÖ¤¹¡£
150 .\"O It returns 0, if a L\(aq\\0\(aq wide character was recognized.
151 .\"O It returns
152 .\"O .I (size_t)\ \-1
153 .\"O and sets \fIerrno\fP to \fBEILSEQ\fP, if an invalid multibyte sequence was
154 .\"O encountered.
155 .\"O It returns \fI(size_t)\ \-2\fP if it couldn't parse a complete multibyte
156 .\"O character, meaning that \fIn\fP should be increased.
157 L\(aq\\0\(aq ¥ï¥¤¥Éʸ»ú¤òǧ¼±¤·¤¿¾ì¹ç¤Ë¤Ï 0 ¤òÊÖ¤¹¡£
158 ÉÔÀµ¤Ê¥Þ¥ë¥Á¥Ð¥¤¥ÈÎó¤ËÁø¶ø¤·¤¿¾ì¹ç¤Ë¤Ï
159 .I (size_t)\ \-1
160 ¤òÊÖ¤·¡¢
161 \fIerrno\fP ¤Ë \fBEILSEQ\fP ¤òÀßÄꤹ¤ë¡£´°Á´¤Ê¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»ú¤ò
162 ²òÀϤǤ­¤Ê¤«¤Ã¤¿¾ì¹ç¤Ë¤Ï
163 .I (size_t)\ \-2
164 ¤òÊÖ¤· \fIn\fP ¤òÁý²Ã¤µ¤»¤ëɬÍפ¬¤¢¤ë¤³¤È¤ò¼¨¤¹¡£
165 .\"O .SH "CONFORMING TO"
166 .SH ½àµò
167 C99.
168 .\"O .SH NOTES
169 .SH Ãí°Õ
170 .\"O The behavior of
171 .\"O .BR mbrtowc ()
172 .\"O depends on the
173 .\"O .B LC_CTYPE
174 .\"O category of the
175 .\"O current locale.
176 .BR mbrtowc ()
177 ¤ÎÆ°ºî¤Ï¸½ºß¤Î¥í¥±¡¼¥ë¤Î
178 .B LC_CTYPE
179 ¥«¥Æ¥´¥ê¤Ë°Í¸¤·¤Æ¤¤¤ë¡£
180 .\"O .SH "SEE ALSO"
181 .SH ´ØÏ¢¹àÌÜ
182 .BR mbsrtowcs (3)