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 http://www.UNIX-systems.org/online.html
13 .\" Japanese Version Copyright (c) 1999 HANATAKA Shinya
14 .\" all rights reserved.
15 .\" Translated Tue Jan 11 00:56:10 JST 2000
16 .\" by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
18 .TH MBSNRTOWCS 3 2010-09-15 "GNU" "Linux Programmer's Manual"
21 .\"O mbsnrtowcs \- convert a multibyte string to a wide-character string
22 mbsnrtowcs \- ¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎó¤ò¥ï¥¤¥Éʸ»úÎó¤ËÊÑ´¹¤¹¤ë
28 .BI "size_t mbsnrtowcs(wchar_t *" dest ", const char **" src ,
29 .BI " size_t " nms ", size_t " len ", mbstate_t *" ps );
33 .\"O Feature Test Macro Requirements for glibc (see
34 .\"O .BR feature_test_macros (7)):
35 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
36 .RB ( feature_test_macros (7)
45 .\"O Since glibc 2.10:
47 _XOPEN_SOURCE\ >=\ 700 || _POSIX_C_SOURCE\ >=\ 200809L
49 .\"O Before glibc 2.10:
58 .\"O .BR mbsnrtowcs ()
59 .\"O function is like the
60 .\"O .BR mbsrtowcs (3)
61 .\"O function, except that
62 .\"O the number of bytes to be converted, starting at \fI*src\fP, is limited to
68 ÊÑ´¹¤¹¤ë¥Ð¥¤¥È¿ô¤¬ \fI*src\fP ¤«¤é»Ï¤Þ¤ë \fInms\fP ¥Ð¥¤¥È¤ËÀ©¸Â¤µ¤ì¤Æ¤¤¤ë
71 .\"O If \fIdest\fP is not a NULL pointer, the
72 .\"O .BR mbsnrtowcs ()
73 .\"O function converts at
74 .\"O most \fInms\fP bytes from the
75 .\"O multibyte string \fI*src\fP to a wide-character string starting at \fIdest\fP.
76 .\"O At most \fIlen\fP wide characters are written to \fIdest\fP.
78 .\"O \fI*ps\fP is updated.
79 .\"O The conversion is effectively performed by repeatedly
81 .\"O .I "mbrtowc(dest, *src, n, ps)"
82 .\"O where \fIn\fP is some
83 .\"O positive number, as long as this call succeeds, and then incrementing
84 .\"O \fIdest\fP by one and \fI*src\fP by the number of bytes consumed.
86 .\"O conversion can stop for three reasons:
87 \fIdest\fP ¤¬ NULL ¥Ý¥¤¥ó¥¿¡¼¤Ç¤Ê¤±¤ì¤Ð
90 \fI*src\fP ¤«¤é¤Î¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎó¤ÎºÇÂç \fInms\fP ¤Þ¤Ç¤ò
91 \fIdest\fP ¤«¤é¤Î¥ï¥¤¥Éʸ»úÎó¤ËÊÑ´¹¤¹¤ë¡£
92 ºÇÂç \fIlen\fP ʸ»ú¤Î¥ï¥¤¥Éʸ»ú¤¬ \fIdest\fP ¤Ë½ñ¤¹þ¤Þ¤ì¤ë¡£
93 Ʊ»þ¤Ë¥·¥Õ¥È¾õÂÖ \fI*ps\fP ¤ò¹¹¿·¤¹¤ë¡£
95 .I "mbrtowc(dest, *src, n, ps)"
96 ¤ò¡¢¤³¤Î¸Æ¤Ó½Ð¤·¤¬À®¸ù¤¹¤ë¸Â¤ê¡¢·«¤êÊÖ¤·¼Â¹Ô¤·¤¿¤Î¤È¼Â¼ÁŪ¤ËƱÍͤǤ¢¤ë¡£
97 ¤³¤³¤Ç¤Î \fIn\fP ¤ÏÀµ¤Î¿ô¤Ç¤¢¤ê¡¢·«¤êÊÖ¤·¤´¤È¤Ë \fIdest\fP ¤¬ 1 Áý²Ã¤µ¤»¤é¤ì¡¢
98 \fI*src\fP ¤¬¾ÃÈñ¤·¤¿¥Ð¥¤¥È¿ô¤À¤±Áý²Ã¤µ¤»¤é¤ì¤ë¡£ÊÑ´¹¤Ï°Ê²¼¤Î»°¤Ä¤Î
99 ¤¤¤º¤ì¤«¤Î¾ò·ï¤ÇÄä»ß¤¹¤ë:
101 .\"O An invalid multibyte sequence has been encountered.
102 .\"O In this case \fI*src\fP
103 .\"O is left pointing to the invalid multibyte sequence,
104 .\"O .I (size_t)\ \-1
106 .\"O and \fIerrno\fP is set to \fBEILSEQ\fP.
107 ÉÔÀµ¤Ê¥Þ¥ë¥Á¥Ð¥¤¥ÈÎó¤ËÁø¶ø¤·¤¿¡£¤³¤Î¾ì¹ç¤Ë¤Ï \fI*src\fP ¤ÏÉÔÀµ¤Ê
108 ¥Þ¥ë¥Á¥Ð¥¤¥ÈÎó¤ò»Ø¤¹¤è¤¦¤Ë¤·¤Æ¡¢
110 ¤òÊÖ¤·¡¢\fIerrno\fP ¤Ë \fBEILSEQ\fP ¤òÀßÄꤹ¤ë¡£
112 .\"O The \fInms\fP limit forces a stop,
113 .\"O or \fIlen\fP non-L\(aq\\0\(aq wide characters
114 .\"O have been stored at \fIdest\fP.
115 .\"O In this case \fI*src\fP is left pointing to the
116 .\"O next multibyte sequence to be converted, and the number of wide characters
117 .\"O written to \fIdest\fP is returned.
118 \fInms\fP À©¸Â¤Ë¤è¤Ã¤Æ¶¯À©Åª¤ËÄä»ß¤¹¤ë¤«¡¢\fIlen\fP ʸ»ú¤Î L\(aq\\0\(aq °Ê³°¤Î
119 ¥ï¥¤¥Éʸ»ú¤ò \fIdest\fP ¤Ë³ÊǼ¤·¤¿¾ì¹ç¡£¤³¤Î¾ì¹ç¤Ï \fI*src\fP ¤Ï
120 ¼¡¤ËÊÑ´¹¤µ¤ì¤ë¥Þ¥ë¥Á¥Ð¥¤¥ÈÎó¤ò»Ø¤¹¤è¤¦¤Ë¤·¤Æ¡¢\fIdest\fP ¤Ë½ñ¤¹þ¤Þ¤ì¤¿
121 ¥ï¥¤¥Éʸ»ú¤Î¿ô¤òÊÖ¤¹¡£
123 .\"O The multibyte string has been completely converted, including the
124 .\"O terminating \(aq\\0\(aq
125 .\"O (which has the side effect of bringing back \fI*ps\fP to the
127 .\"O In this case \fI*src\fP is set to NULL, and the number of wide
128 .\"O characters written to \fIdest\fP,
129 .\"O excluding the terminating L\(aq\\0\(aq character,
131 ¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎ󤬽ªÃ¼¤Î \(aq\\0\(aq ¤Þ¤Ç´Þ¤á¤Æ´°Á´¤ËÊÑ´¹¤µ¤ì¤¿¾ì¹ç¡£
132 (¤³¤Î»þ¡¢ÉûºîÍѤȤ·¤Æ \fI*ps\fP ¤¬½é´ü¾õÂÖ¤ËÌᤵ¤ì¤ë¡£)
133 ¤³¤Î¾ì¹ç¤Ï \fI*src\fP ¤Ë¤Ï NULL ¤¬ÀßÄꤵ¤ì¡¢½ªÃ¼¤Î L\(aq\\0\(aq ʸ»ú¤ò½ü¤¤¤Æ
134 \fIdest\fP ¤Ë½ñ¤¹þ¤Þ¤ì¤¿Ê¸»ú¿ô¤òÊÖ¤¹¡£
136 .\"O If \fIdest\fP is NULL, \fIlen\fP is ignored, and the conversion proceeds as
137 .\"O above, except that the converted wide characters
138 .\"O are not written out to memory,
139 .\"O and that no destination length limit exists.
140 \fIdest\fP ¤¬ NULL ¤Î¾ì¹ç¡¢\fIlen\fP ¤Ï̵»ë¤µ¤ì¡¢¾åµ¤ÈƱÍͤÎÊÑ´¹¤¬
141 ¹Ô¤ï¤ì¤ë¤¬¡¢ÊÑ´¹¤µ¤ì¤¿¥ï¥¤¥Éʸ»ú¤Ï¥á¥â¥ê¤Ë½ñ¤¹þ¤Þ¤ì¤º¡¢ÊÑ´¹Àè¤Î¾å¸Â
144 .\"O In both of the above cases, if \fIps\fP is a NULL pointer, a static anonymous
145 .\"O state only known to the mbsnrtowcs function is used instead.
146 ¾åµ¤Î¤É¤Á¤é¤Î¾ì¹ç¤Ç¤â¡¢\fIps\fP ¤¬ NULL ¥Ý¥¤¥ó¥¿¡¼¤Ê¤é¤Ð¡¢Âå¤ê¤Ë
147 mbsnrtowcs ´Ø¿ô¤Î¤ß¤¬»ÈÍѤ¹¤ëÀÅŪ¤Ç̾Á°¤Î¤Ê¤¤¾õÂÖ¤¬»ÈÍѤµ¤ì¤ë¡£
149 .\"O The programmer must ensure that there is room for at least \fIlen\fP wide
150 .\"O characters at \fIdest\fP.
151 ¥×¥í¥°¥é¥Þ¡¼¤Ï \fIdest\fP ¤ËºÇÄã¤Ç¤â \fIlen\fP ¥ï¥¤¥Éʸ»ú¤ò½ñ¤¹þ¤à¤³
152 ¤È¤¬¤Ç¤¤ë¶õ´Ö¤¬¤¢¤ë¤³¤È¤òÊݾڤ·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
153 .\"O .SH "RETURN VALUE"
156 .\"O .BR mbsnrtowcs ()
157 .\"O function returns the number of wide characters
158 .\"O that make up the converted part of the wide-character string,
159 .\"O not including the terminating null wide character.
160 .\"O If an invalid multibyte sequence was
162 .\"O .I (size_t)\ \-1
163 .\"O is returned, and \fIerrno\fP set to \fBEILSEQ\fP.
165 ´Ø¿ô¤Ï¥ï¥¤¥Éʸ»úÎó¤ËÊÑ´¹´°Î»¤·¤¿¥ï¥¤¥Éʸ»ú¤Î¿ô¤òÊÖ¤¹¡£
166 ½ªÃ¼¤Î¥Ê¥ë¥ï¥¤¥Éʸ»ú¤Ï´Þ¤Þ¤Ê¤¤¡£ÉÔÀµ¤Ê¥Þ¥ë¥Á¥Ð¥¤¥ÈÎó¤ËÁø¶ø¤·¤¿¾ì¹ç¤Ë¤Ï
168 ¤òÊÖ¤·¡¢\fIerrno\fP ¤Ë \fBEILSEQ\fP ¤òÀßÄꤹ¤ë¡£
169 .\"O .SH "CONFORMING TO"
171 .\"O This function is a GNU extension.
172 ¤³¤Î´Ø¿ô¤Ï GNU ¤Î³ÈÄ¥¤Ç¤¢¤ë¡£
176 .\"O .BR mbsnrtowcs ()
182 ¤ÎÆ°ºî¤Ï¸½ºß¤Î¥í¥±¡¼¥ë¤Î
184 ¥«¥Æ¥´¥ê¤Ë°Í¸¤·¤Æ¤¤¤ë¡£
186 .\"O Passing NULL as \fIps\fP is not multithread safe.
187 \fIps\fP ¤È¤·¤Æ NULL ¤òÅϤ¹¤³¤È¤Ï¥Þ¥ë¥Á¥¹¥ì¥Ã¥É¤Ç¤Ï°ÂÁ´¤Ç¤Ê¤¤¡£