OSDN Git Service

72477940c2e291aae9929d7aaf1232e5b74bcd3a
[linuxjm/LDP_man-pages.git] / draft / man3 / mbsrtowcs.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 .\" 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>
18 .\"
19 .TH MBSRTOWCS 3 1999-07-25 "GNU" "Linux Programmer's Manual"
20 .\"O .SH NAME
21 .SH Ì¾Á°
22 .\"O mbsrtowcs \- convert a multibyte string to a wide-character string
23 mbsrtowcs \- ¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎó¤ò¥ï¥¤¥Éʸ»úÎó¤ËÊÑ´¹¤¹¤ë
24 .\"O .SH SYNOPSIS
25 .SH ½ñ¼°
26 .nf
27 .B #include <wchar.h>
28 .sp
29 .BI "size_t mbsrtowcs(wchar_t *" dest ", const char **" src ,
30 .BI "                  size_t " len ", mbstate_t *" ps );
31 .fi
32 .\"O .SH DESCRIPTION
33 .SH ÀâÌÀ
34 .\"O If \fIdest\fP is not a NULL pointer, the
35 .\"O .BR mbsrtowcs ()
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.
39 .\"O The shift state
40 .\"O \fI*ps\fP is updated.
41 .\"O The conversion is effectively performed by repeatedly
42 .\"O calling
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 ¥Ý¥¤¥ó¥¿¡¼¤Ç¤Ê¤±¤ì¤Ð¡¢
49 .BR mbsrtowcs ()
50 ´Ø¿ô¤Ï
51 ¥Þ¥ë¥Á¥Ð¥¤¥Èʸ»úÎó \fI*src\fP ¤ò \fIdest\fP ¤«¤é»Ï¤Þ¤ë¥ï¥¤¥Éʸ»úÎó¤Ë
52 ÊÑ´¹¤¹¤ë¡£\fIdest\fP ¤Ë¤ÏºÇÂç¤Ç \fIlen\fP Ê¸»ú¤Î¥ï¥¤¥Éʸ»ú¤¬
53 ½ñ¤­¹þ¤Þ¤ì¤ë¡£Æ±»þ¤Ë¥·¥Õ¥È¾õÂÖ \fI*ps\fP ¤ò¹¹¿·¤¹¤ë¡£
54 ÊÑ´¹¤Ï
55 .I "mbrtowc(dest, *src, n, ps)"
56 ¤ò¡¢¤³¤Î¸Æ¤Ó½Ð¤·¤¬À®¸ù¤¹¤ë¸Â¤ê·«¤êÊÖ¤·¼Â¹Ô¤·¤¿¤Î¤È¼Â¼ÁŪ¤ËƱÍͤǤ¢¤ë¡£
57 ¤³¤³¤Ç \fIn\fP ¤ÏÀµ¤Î¿ô¤Ç¤¢¤ê¡¢·«¤êÊÖ¤·¤´¤È¤Ë \fIdest\fP ¤¬ 1 Áý²Ã¤µ¤»¤é¤ì¡¢
58 \fI*src\fP ¤¬¾ÃÈñ¤·¤¿¥Ð¥¤¥È¿ô¤À¤±Áý²Ã¤µ¤»¤é¤ì¤ë¡£ÊÑ´¹¤Ï°Ê²¼¤Î»°¤Ä¤Î
59 ¤¤¤º¤ì¤«¤Î¾ò·ï¤ÇÄä»ß¤¹¤ë:
60 .IP 1. 3
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,
64 .\"O .I (size_t)\ \-1
65 .\"O is returned,
66 .\"O and \fIerrno\fP is set to \fBEILSEQ\fP.
67 ÉÔÀµ¤Ê¥Þ¥ë¥Á¥Ð¥¤¥ÈÎó¤ËÁø¶ø¤·¤¿¡£¤³¤Î¾ì¹ç¤Ë¤Ï \fI*src\fP ¤ÏÉÔÀµ¤Ê
68 ¥Þ¥ë¥Á¥Ð¥¤¥ÈÎó¤ò»Ø¤¹¤è¤¦¤Ë¤·¤Æ¡¢
69 .I (size_t)\ \-1
70 ¤òÊÖ¤·¡¢\fIerrno\fP ¤Ë \fBEILSEQ\fP ¤òÀßÄꤹ¤ë¡£
71 .IP 2.
72 .\"O \fIlen\fP non-L\(aq\\0\(aq wide characters have been stored at \fIdest\fP.
73 .\"O In this
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 ¤Ë½ñ¤­¹þ¤Þ¤ì¤¿¥ï¥¤¥Éʸ»ú¤Î¿ô¤òÊÖ¤¹¡£
80 .IP 3.
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
84 .\"O initial state).
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 ¤Ë½ñ¤­¹þ¤Þ¤ì¤¿Ê¸»ú¿ô¤òÊÖ¤¹¡£
92 .PP
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 ¹Ô¤ï¤ì¤ë¤¬¡¢ÊÑ´¹¤µ¤ì¤¿¥ï¥¤¥Éʸ»ú¤Ï¥á¥â¥ê¤Ë½ñ¤­¹þ¤Þ¤ì¤º¡¢ÊÑ´¹Àè¤Î¾å¸Â
99 ¤¬Â¸ºß¤·¤Ê¤¤¡£
100 .PP
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 ¥Ý¥¤¥ó¥¿¡¼¤Ê¤é¤Ð¡¢
107 Âå¤ê¤Ë
108 .BR mbsrtowcs ()
109 ´Ø¿ô¤Î¤ß¤¬»ÈÍѤ¹¤ëÀÅŪ¤Ç̾Á°¤Î¤Ê¤¤¾õÂÖ¤¬»ÈÍѤµ¤ì¤ë¡£
110 .PP
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"
116 .SH ÊÖ¤êÃÍ
117 .\"O The
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
123 .\"O encountered,
124 .\"O .I (size_t)\ \-1
125 .\"O is returned, and \fIerrno\fP set to \fBEILSEQ\fP.
126 .BR mbsrtowcs ()
127 ´Ø¿ô¤Ï¥ï¥¤¥Éʸ»úÎó¤ËÊÑ´¹´°Î»¤·¤¿¥ï¥¤¥Éʸ»ú¤Î¿ô¤òÊÖ¤¹¡£
128 ½ªÃ¼¤Î¥Ê¥ë¥ï¥¤¥Éʸ»ú¤Ï´Þ¤Þ¤Ê¤¤¡£ÉÔÀµ¤Ê¥Þ¥ë¥Á¥Ð¥¤¥ÈÎó¤ËÁø¶ø¤·¤¿¾ì¹ç¤Ë¤Ï
129 .I (size_t)\ \-1
130 ¤òÊÖ¤·¡¢\fIerrno\fP ¤Ë \fBEILSEQ\fP ¤òÀßÄꤹ¤ë¡£
131 .\"O .SH "CONFORMING TO"
132 .SH ½àµò
133 C99.
134 .\"O .SH NOTES
135 .SH Ãí°Õ
136 .\"O The behavior of
137 .\"O .BR mbsrtowcs ()
138 .\"O depends on the
139 .\"O .B LC_CTYPE
140 .\"O category of the
141 .\"O current locale.
142 .BR mbsrtowcs ()
143 ¤ÎÆ°ºî¤Ï¸½ºß¤Î¥í¥±¡¼¥ë¤Î
144 .B LC_CTYPE
145 ¥«¥Æ¥´¥ê¤Ë°Í¸¤·¤Æ¤¤¤ë¡£
146 .PP
147 .\"O Passing NULL as \fIps\fP is not multithread safe.
148 \fIps\fP ¤È¤·¤Æ NULL ¤òÅϤ¹¤³¤È¤Ï¥Þ¥ë¥Á¥¹¥ì¥Ã¥É¤Ç¤Ï°ÂÁ´¤Ç¤Ê¤¤¡£
149 .\"O .SH "SEE ALSO"
150 .SH ´ØÏ¢¹àÌÜ
151 .BR iconv (3),
152 .BR mbsnrtowcs (3),
153 .BR mbstowcs (3)