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:13 JST 2000
17 .\" by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
19 .\"WORD: initial shift state ½é´ü¥·¥Õ¥È¾õÂÖ
21 .TH MBSINIT 3 2000-11-20 "GNU" "Linux Programmer's Manual"
24 .\"O mbsinit \- test for initial shift state
25 mbsinit \- ½é´ü¥·¥Õ¥È¾õÂÖ¤«¤É¤¦¤«¤ò¸¡ºº¤¹¤ë
31 .BI "int mbsinit(const mbstate_t *" ps );
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 ¤Î¤è¤¦¤ÊÉä¹æ¤ò°·¤¦¤Î¤ËɬÍפȤµ¤ì¤ë¡£
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 ½é´ü¾õÂ֤ȤÏʸ»úÎó¤ÎÊÑ´¹¤ò³«»Ï¤¹¤ë»þ¤Î¾õÂ֤Ǥ¢¤ë¡£¾õÂ֤ˤÏÆó¼ïÎब
60 ¤Î¤è¤¦¤Ê¥Þ¥ë¥Á¥Ð¥¤¥È¤ò¥ï¥¤¥Éʸ»ú¤Ë
61 ÊÑ´¹¤¹¤ë´Ø¿ô¤Ç»ÈÍѤµ¤ì¤ë¡£¤â¤¦°ì¤Ä¤Ï
64 ¥ï¥¤¥Éʸ»ú¤ò¥Þ¥ë¥Á¥Ð¥¤¥È¤ËÊÑ´¹¤¹¤ë´Ø¿ô¤Ç»ÈÍѤµ¤ì¤ë¡£¤·¤«¤·Î¾Êý¤È¤â
65 \fImbstate_t\fP ¤Ë³ÊǼ¤µ¤ì¡¢½é´ü¾õÂ֤Ȥ·¤ÆƱ¤¸É½¸½¤ò»ý¤Ä¡£
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
73 .\"O produce non-initial states when interrupted in the middle of a character.
74 8¥Ó¥Ã¥ÈÉä¹æ¤Ë¤ª¤¤¤Æ¤ÏÁ´¤Æ¤Î¾õÂ֤Ͻé´ü¾õÂÖ¤ÈÅù²Á¤Ç¤¢¤ë¡£
75 UTF-8, EUC-*, BIG5, SJIS ¤Î¤è¤¦¤Ê¿¥Ð¥¤¥ÈÉä¹æ¤Ë¤ª¤¤¤Æ¥ï¥¤¥Éʸ»ú¤«¤é
76 ¿¥Ð¥¤¥Èʸ»ú¤Ø¤ÎÊÑ´¹´Ø¿ô¤ÏÈó½é´ü¾õÂ֤ˤϤʤé¤Ê¤¤¡£
79 ¤Î¤è¤¦¤Ê¿¥Ð¥¤¥Èʸ»ú¤«¤é¥ï¥¤¥Éʸ»ú¤Ø¤ÎÊÑ´¹´Ø¿ô¤Ç¤Ï
80 ʸ»ú¤Î²ò¼á¤ÎÅÓÃæ¤ÇÈó½é´ü¾õÂ֤Ȥʤë¾ì¹ç¤¬¤¢¤ë¡£
82 .\"O One possible way to create an
85 .\"O state is to set it to zero:
88 ¤òºîÀ®¤¹¤ëÊýË¡¤Î°ì¤Ä¤Ï¡¢¤½¤ì¤ò¥¼¥í¤ËÀßÄꤹ¤ë¤³¤È¤Ç¤¢¤ë:
92 memset(&state,0,sizeof(mbstate_t));
95 .\"O On Linux, the following works as well, but might generate compiler warnings:
96 Linux ¤Ë¤ª¤¤¤Æ¤Ï°Ê²¼¤ÎÊýË¡¤Ç¤âƱÍͤǤ¢¤ë¤¬¡¢¥³¥ó¥Ñ¥¤¥é¡¼¤Î·Ù¹ð¤¬
97 À¸À®¤µ¤ì¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
100 mbstate_t state = { 0 };
105 .\"O tests whether \fI*ps\fP corresponds to an
108 ¤Ï \fI*ps\fP ¤¬½é´ü¾õÂ֤˰ìÃפ¹¤ë¤«¤É¤¦¤«¤ò¸¡ºº¤¹¤ë¡£
109 .\"O .SH "RETURN VALUE"
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.
116 ¤Ï \fI*ps\fP ¤¬½é´ü¾õÂ֤ξì¹ç¤ä NULL ¥Ý¥¤¥ó¥¿¡¼¤Î¾ì¹ç¤Ë¤Ï
117 ¥¼¥í°Ê³°¤òÊÖ¤¹¡£¤½¤ì°Ê³°¤Î¾ì¹ç¤Ë¤Ï¥¼¥í¤òÊÖ¤¹¡£
118 .\"O .SH "CONFORMING TO"
130 ¤ÎÆ°ºî¤Ï¸½ºß¤Î¥í¥±¡¼¥ë¤Î
132 ¥«¥Æ¥´¥ê¤Ë°Í¸¤·¤Æ¤¤¤ë¡£