OSDN Git Service

(split) Apply minor changes from v3.32 to v3.35 in the upstream.
[linuxjm/LDP_man-pages.git] / draft / man3 / mbsinit.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:13 JST 2000
17 .\"         by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
18 .\"
19 .\"WORD:        initial shift state             ½é´ü¥·¥Õ¥È¾õÂÖ
20 .\"
21 .TH MBSINIT 3  2000-11-20 "GNU" "Linux Programmer's Manual"
22 .\"O .SH NAME
23 .SH Ì¾Á°
24 .\"O mbsinit \- test for initial shift state
25 mbsinit \- ½é´ü¥·¥Õ¥È¾õÂÖ¤«¤É¤¦¤«¤ò¸¡ºº¤¹¤ë
26 .\"O .SH SYNOPSIS
27 .SH ½ñ¼°
28 .nf
29 .B #include <wchar.h>
30 .sp
31 .BI "int mbsinit(const mbstate_t *" ps );
32 .fi
33 .\"O .SH DESCRIPTION
34 .SH ÀâÌÀ
35 .\"O Character conversion between the multibyte representation and the wide
36 .\"O character representation uses conversion state, of type \fImbstate_t\fP.
37 .\"O Conversion of a string uses a finite-state machine; when it is interrupted
38 .\"O after the complete conversion of a number of characters, it may need to
39 .\"O save a state for processing the remaining characters.
40 .\"O Such a conversion
41 .\"O state is needed for the sake of encodings such as ISO-2022 and UTF-7.
42 ʸ»ú¤ò¥Þ¥ë¥Á¥Ð¥¤¥Èɽ¸½¤È¥ï¥¤¥Éʸ»úɽ¸½¤Î´Ö¤ÇÊÑ´¹¤¹¤ë¾ì¹ç¤Ë¤Ï
43 \fImbstate_t\fP ·¿¤ÎÊÑ´¹¾õÂÖ¤ò»ÈÍѤ¹¤ë¡£Ê¸»úÎó¤ÎÊÑ´¹¤ÏÍ­¸Â¾õÂÖ¥Þ¥·¥ó
44 ¤ò»ÈÍѤ¹¤ë¡£¤¤¤¯¤é¤«¤Îʸ»ú¤ÎÊÑ´¹¤ò´°Î»¤·¤¿¸å¤Ë¡¢»Ä¤ê¤Îʸ»ú¤ò½èÍý¤¹¤ë
45 ¤¿¤á¤Ë¾õÂÖ¤òÊݸ¤·¤Æ¤ª¤¯É¬Íפ¬¤¢¤ë¤«¤â¤·¤ì¤Ê¤¤¡£¤³¤Î¤è¤¦¤ÊÊÑ´¹¾õÂÖ¤Ï
46 ISO-2022 ¤ä UTF-7 ¤Î¤è¤¦¤ÊÉä¹æ¤ò°·¤¦¤Î¤ËɬÍפȤµ¤ì¤ë¡£
47 .PP
48 .\"O The initial state is the state at the beginning of conversion of a string.
49 .\"O There are two kinds of state: The one used by multibyte to wide character
50 .\"O conversion functions, such as
51 .\"O .BR mbsrtowcs (3),
52 .\"O and the one used by wide
53 .\"O character to multibyte conversion functions, such as
54 .\"O .BR wcsrtombs (3),
55 .\"O but they both fit in a \fImbstate_t\fP, and they both have the same
56 .\"O representation for an initial state.
57 ½é´ü¾õÂ֤ȤÏʸ»úÎó¤ÎÊÑ´¹¤ò³«»Ï¤¹¤ë»þ¤Î¾õÂ֤Ǥ¢¤ë¡£¾õÂ֤ˤÏÆó¼ïÎब
58 ¸ºß¤·¡¢°ì¤Ä¤Ï
59 .BR mbsrtowcs (3)
60 ¤Î¤è¤¦¤Ê¥Þ¥ë¥Á¥Ð¥¤¥È¤ò¥ï¥¤¥Éʸ»ú¤Ë
61 ÊÑ´¹¤¹¤ë´Ø¿ô¤Ç»ÈÍѤµ¤ì¤ë¡£¤â¤¦°ì¤Ä¤Ï
62 .BR wcsrtombs (3)
63 ¤Î¤è¤¦¤Ê
64 ¥ï¥¤¥Éʸ»ú¤ò¥Þ¥ë¥Á¥Ð¥¤¥È¤ËÊÑ´¹¤¹¤ë´Ø¿ô¤Ç»ÈÍѤµ¤ì¤ë¡£¤·¤«¤·Î¾Êý¤È¤â
65 \fImbstate_t\fP ¤Ë³ÊǼ¤µ¤ì¡¢½é´ü¾õÂ֤Ȥ·¤ÆƱ¤¸É½¸½¤ò»ý¤Ä¡£
66 .PP
67 .\"O For 8-bit encodings, all states are equivalent to the initial state.
68 .\"O For multibyte encodings like UTF-8, EUC-*, BIG5 or SJIS, the wide character
69 .\"O to multibyte conversion functions never produce non-initial states, but the
70 .\"O multibyte to wide-character conversion functions like
71 .\"O .BR mbrtowc (3)
72 .\"O do
73 .\"O produce non-initial states when interrupted in the middle of a character.
74 8¥Ó¥Ã¥ÈÉä¹æ¤Ë¤ª¤¤¤Æ¤ÏÁ´¤Æ¤Î¾õÂ֤Ͻé´ü¾õÂÖ¤ÈÅù²Á¤Ç¤¢¤ë¡£
75 UTF-8, EUC-*, BIG5, SJIS ¤Î¤è¤¦¤Ê¿¥Ð¥¤¥ÈÉä¹æ¤Ë¤ª¤¤¤Æ¥ï¥¤¥Éʸ»ú¤«¤é
76 ¿¥Ð¥¤¥Èʸ»ú¤Ø¤ÎÊÑ´¹´Ø¿ô¤ÏÈó½é´ü¾õÂ֤ˤϤʤé¤Ê¤¤¡£
77 ¤·¤«¤·
78 .BR mbrtowc (3)
79 ¤Î¤è¤¦¤Ê¿¥Ð¥¤¥Èʸ»ú¤«¤é¥ï¥¤¥Éʸ»ú¤Ø¤ÎÊÑ´¹´Ø¿ô¤Ç¤Ï
80 ʸ»ú¤Î²ò¼á¤ÎÅÓÃæ¤ÇÈó½é´ü¾õÂ֤Ȥʤë¾ì¹ç¤¬¤¢¤ë¡£
81 .PP
82 .\"O One possible way to create an
83 .\"O .I mbstate_t
84 .\"O in initial
85 .\"O state is to set it to zero:
86 ½é´ü¾õÂÖ¤Î
87 .I mbstate_t
88 ¤òºîÀ®¤¹¤ëÊýË¡¤Î°ì¤Ä¤Ï¡¢¤½¤ì¤ò¥¼¥í¤ËÀßÄꤹ¤ë¤³¤È¤Ç¤¢¤ë:
89 .nf
90
91     mbstate_t state;
92     memset(&state,0,sizeof(mbstate_t));
93 .fi
94 .PP
95 .\"O On Linux, the following works as well, but might generate compiler warnings:
96 Linux ¤Ë¤ª¤¤¤Æ¤Ï°Ê²¼¤ÎÊýË¡¤Ç¤âƱÍͤǤ¢¤ë¤¬¡¢¥³¥ó¥Ñ¥¤¥é¡¼¤Î·Ù¹ð¤¬
97 À¸À®¤µ¤ì¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
98 .nf
99
100     mbstate_t state = { 0 };
101 .fi
102 .PP
103 .\"O The function
104 .\"O .BR mbsinit ()
105 .\"O tests whether \fI*ps\fP corresponds to an
106 .\"O initial state.
107 .BR mbsinit ()
108 ¤Ï \fI*ps\fP ¤¬½é´ü¾õÂ֤˰ìÃפ¹¤ë¤«¤É¤¦¤«¤ò¸¡ºº¤¹¤ë¡£
109 .\"O .SH "RETURN VALUE"
110 .SH ÊÖ¤êÃÍ
111 .\"O .BR mbsinit ()
112 .\"O returns nonzero if \fI*ps\fP is an initial state, or if
113 .\"O \fIps\fP is a NULL pointer.
114 .\"O Otherwise it returns 0.
115 .BR mbsinit ()
116 ¤Ï \fI*ps\fP ¤¬½é´ü¾õÂ֤ξì¹ç¤ä NULL ¥Ý¥¤¥ó¥¿¡¼¤Î¾ì¹ç¤Ë¤Ï
117 ¥¼¥í°Ê³°¤òÊÖ¤¹¡£¤½¤ì°Ê³°¤Î¾ì¹ç¤Ë¤Ï¥¼¥í¤òÊÖ¤¹¡£
118 .\"O .SH "CONFORMING TO"
119 .SH ½àµò
120 C99.
121 .\"O .SH NOTES
122 .SH Ãí°Õ
123 .\"O The behavior of
124 .\"O .BR mbsinit ()
125 .\"O depends on the
126 .\"O .B LC_CTYPE
127 .\"O category of the
128 .\"O current locale.
129 .BR mbsinit ()
130 ¤ÎÆ°ºî¤Ï¸½ºß¤Î¥í¥±¡¼¥ë¤Î
131 .B LC_CTYPE
132 ¥«¥Æ¥´¥ê¤Ë°Í¸¤·¤Æ¤¤¤ë¡£
133 .\"O .SH "SEE ALSO"
134 .SH ´ØÏ¢¹àÌÜ
135 .BR mbsrtowcs (3),
136 .BR wcsrtombs (3)