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
14 .\" Japanese Version Copyright (c) 1999 HANATAKA Shinya
15 .\" all rights reserved.
16 .\" Translated Tue Jan 11 00:56:08 JST 2000
17 .\" by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
19 .TH MBSRTOWCS 3 1999-07-25 "GNU" "Linux Programmer's Manual"
22 .\"O mbsrtowcs \- convert a multibyte string to a wide-character string
23 mbsrtowcs \- ¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎó¤ò¥ï¥¤¥Éʸ»úÎó¤ËÊÑ´¹¤¹¤ë
29 .BI "size_t mbsrtowcs(wchar_t *" dest ", const char **" src ,
30 .BI " size_t " len ", mbstate_t *" ps );
34 .\"O If \fIdest\fP is not a NULL pointer, the
36 .\"O function converts the
37 .\"O multibyte string \fI*src\fP to a wide-character string starting at \fIdest\fP.
38 .\"O At most \fIlen\fP wide characters are written to \fIdest\fP.
40 .\"O \fI*ps\fP is updated.
41 .\"O The conversion is effectively performed by repeatedly
43 .\"O .I "mbrtowc(dest, *src, n, ps)"
44 .\"O where \fIn\fP is some
45 .\"O positive number, as long as this call succeeds, and then incrementing
46 .\"O \fIdest\fP by one and \fI*src\fP by the number of bytes consumed.
47 .\"O The conversion can stop for three reasons:
48 \fIdest\fP ¤¬ NULL ¥Ý¥¤¥ó¥¿¡¼¤Ç¤Ê¤±¤ì¤Ð¡¢
51 ¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎó \fI*src\fP ¤ò \fIdest\fP ¤«¤é»Ï¤Þ¤ë¥ï¥¤¥Éʸ»úÎó¤Ë
52 ÊÑ´¹¤¹¤ë¡£\fIdest\fP ¤Ë¤ÏºÇÂç¤Ç \fIlen\fP ʸ»ú¤Î¥ï¥¤¥Éʸ»ú¤¬
53 ½ñ¤¹þ¤Þ¤ì¤ë¡£Æ±»þ¤Ë¥·¥Õ¥È¾õÂÖ \fI*ps\fP ¤ò¹¹¿·¤¹¤ë¡£
55 .I "mbrtowc(dest, *src, n, ps)"
56 ¤ò¡¢¤³¤Î¸Æ¤Ó½Ð¤·¤¬À®¸ù¤¹¤ë¸Â¤ê·«¤êÊÖ¤·¼Â¹Ô¤·¤¿¤Î¤È¼Â¼ÁŪ¤ËƱÍͤǤ¢¤ë¡£
57 ¤³¤³¤Ç \fIn\fP ¤ÏÀµ¤Î¿ô¤Ç¤¢¤ê¡¢·«¤êÊÖ¤·¤´¤È¤Ë \fIdest\fP ¤¬ 1 Áý²Ã¤µ¤»¤é¤ì¡¢
58 \fI*src\fP ¤¬¾ÃÈñ¤·¤¿¥Ð¥¤¥È¿ô¤À¤±Áý²Ã¤µ¤»¤é¤ì¤ë¡£ÊÑ´¹¤Ï°Ê²¼¤Î»°¤Ä¤Î
59 ¤¤¤º¤ì¤«¤Î¾ò·ï¤ÇÄä»ß¤¹¤ë:
61 .\"O An invalid multibyte sequence has been encountered.
62 .\"O In this case \fI*src\fP
63 .\"O is left pointing to the invalid multibyte sequence,
66 .\"O and \fIerrno\fP is set to \fBEILSEQ\fP.
67 ÉÔÀµ¤Ê¥Þ¥ë¥Á¥Ð¥¤¥ÈÎó¤ËÁø¶ø¤·¤¿¡£¤³¤Î¾ì¹ç¤Ë¤Ï \fI*src\fP ¤ÏÉÔÀµ¤Ê
68 ¥Þ¥ë¥Á¥Ð¥¤¥ÈÎó¤ò»Ø¤¹¤è¤¦¤Ë¤·¤Æ¡¢
70 ¤òÊÖ¤·¡¢\fIerrno\fP ¤Ë \fBEILSEQ\fP ¤òÀßÄꤹ¤ë¡£
72 .\"O \fIlen\fP non-L\(aq\\0\(aq wide characters have been stored at \fIdest\fP.
74 .\"O case \fI*src\fP is left pointing to the next
75 .\"O multibyte sequence to be converted,
76 .\"O and the number of wide characters written to \fIdest\fP is returned.
77 \fIlen\fP ʸ»ú¤Î L\(aq\\0\(aq °Ê³°¤Î¥ï¥¤¥Éʸ»ú¤ò \fIdest\fP ¤Ë³ÊǼ¤·¤¿¾ì¹ç¡£
78 ¤³¤Î¾ì¹ç¤Ï \fI*src\fP ¤Ï¼¡¤ËÊÑ´¹¤µ¤ì¤ë¥Þ¥ë¥Á¥Ð¥¤¥ÈÎó¤ò»Ø¤¹¤è¤¦¤Ë¤·¤Æ¡¢
79 \fIdest\fP ¤Ë½ñ¤¹þ¤Þ¤ì¤¿¥ï¥¤¥Éʸ»ú¤Î¿ô¤òÊÖ¤¹¡£
81 .\"O The multibyte string has been completely converted, including the
82 .\"O terminating \(aq\\0\(aq (which has the side
83 .\"O effect of bringing back \fI*ps\fP to the
85 .\"O In this case \fI*src\fP is set to NULL, and the number of wide
86 .\"O characters written to \fIdest\fP,
87 .\"O excluding the terminating L\(aq\\0\(aq character, is returned.
88 ¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎ󤬽ªÃ¼¤Î \(aq\\0\(aq ¤Þ¤Ç´Þ¤á¤Æ´°Á´¤ËÊÑ´¹¤µ¤ì¤¿¾ì¹ç¡£
89 (¤³¤Î»þ¡¢ÉûºîÍѤȤ·¤Æ \fI*ps\fP ¤¬½é´ü¾õÂÖ¤ËÌᤵ¤ì¤ë¡£)
90 ¤³¤Î¾ì¹ç¤Ï \fI*src\fP ¤Ë¤Ï NULL ¤¬ÀßÄꤵ¤ì¡¢½ªÃ¼¤Î L\(aq\\0\(aq ʸ»ú¤ò½ü¤¤¤Æ
91 \fIdest\fP ¤Ë½ñ¤¹þ¤Þ¤ì¤¿Ê¸»ú¿ô¤òÊÖ¤¹¡£
93 .\"O If \fIdest\fP is NULL, \fIlen\fP is ignored,
94 .\"O and the conversion proceeds as above,
95 .\"O except that the converted wide characters are not written out to memory,
96 .\"O and that no length limit exists.
97 \fIdest\fP ¤¬ NULL ¤Î¾ì¹ç¡¢\fIlen\fP ¤Ï̵»ë¤µ¤ì¡¢¾åµ¤ÈƱÍͤÎÊÑ´¹¤¬
98 ¹Ô¤ï¤ì¤ë¤¬¡¢ÊÑ´¹¤µ¤ì¤¿¥ï¥¤¥Éʸ»ú¤Ï¥á¥â¥ê¤Ë½ñ¤¹þ¤Þ¤ì¤º¡¢ÊÑ´¹Àè¤Î¾å¸Â
101 .\"O In both of the above cases,
102 .\"O if \fIps\fP is a NULL pointer, a static anonymous
103 .\"O state only known to the
104 .\"O .BR mbsrtowcs ()
105 .\"O function is used instead.
106 ¾åµ¤Î¤É¤Á¤é¤Î¾ì¹ç¤Ç¤â¡¢\fIps\fP ¤¬ NULL ¥Ý¥¤¥ó¥¿¡¼¤Ê¤é¤Ð¡¢
109 ´Ø¿ô¤Î¤ß¤¬»ÈÍѤ¹¤ëÀÅŪ¤Ç̾Á°¤Î¤Ê¤¤¾õÂÖ¤¬»ÈÍѤµ¤ì¤ë¡£
111 .\"O The programmer must ensure that there is room for at least \fIlen\fP wide
112 .\"O characters at \fIdest\fP.
113 ¥×¥í¥°¥é¥Þ¡¼¤Ï \fIdest\fP ¤ËºÇÄã¤Ç¤â \fIlen\fP ¥ï¥¤¥Éʸ»ú¤ò½ñ¤¹þ¤à¤³
114 ¤È¤¬¤Ç¤¤ë¶õ´Ö¤¬¤¢¤ë¤³¤È¤òÊݾڤ·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
115 .\"O .SH "RETURN VALUE"
118 .\"O .BR mbsrtowcs ()
119 .\"O function returns the number of wide characters that make
120 .\"O up the converted part of the wide-character string, not including the
121 .\"O terminating null wide character.
122 .\"O If an invalid multibyte sequence was
124 .\"O .I (size_t)\ \-1
125 .\"O is returned, and \fIerrno\fP set to \fBEILSEQ\fP.
127 ´Ø¿ô¤Ï¥ï¥¤¥Éʸ»úÎó¤ËÊÑ´¹´°Î»¤·¤¿¥ï¥¤¥Éʸ»ú¤Î¿ô¤òÊÖ¤¹¡£
128 ½ªÃ¼¤Î¥Ê¥ë¥ï¥¤¥Éʸ»ú¤Ï´Þ¤Þ¤Ê¤¤¡£ÉÔÀµ¤Ê¥Þ¥ë¥Á¥Ð¥¤¥ÈÎó¤ËÁø¶ø¤·¤¿¾ì¹ç¤Ë¤Ï
130 ¤òÊÖ¤·¡¢\fIerrno\fP ¤Ë \fBEILSEQ\fP ¤òÀßÄꤹ¤ë¡£
131 .\"O .SH "CONFORMING TO"
137 .\"O .BR mbsrtowcs ()
143 ¤ÎÆ°ºî¤Ï¸½ºß¤Î¥í¥±¡¼¥ë¤Î
145 ¥«¥Æ¥´¥ê¤Ë°Í¸¤·¤Æ¤¤¤ë¡£
147 .\"O Passing NULL as \fIps\fP is not multithread safe.
148 \fIps\fP ¤È¤·¤Æ NULL ¤òÅϤ¹¤³¤È¤Ï¥Þ¥ë¥Á¥¹¥ì¥Ã¥É¤Ç¤Ï°ÂÁ´¤Ç¤Ê¤¤¡£