1MBSINIT(3) Linux Programmer's Manual MBSINIT(3)
2
3
4
6 mbsinit - test for initial shift state
7
9 #include <wchar.h>
10
11 int mbsinit(const mbstate_t *ps);
12
14 Character conversion between the multibyte representation and the wide
15 character representation uses conversion state, of type mbstate_t.
16 Conversion of a string uses a finite-state machine; when it is inter‐
17 rupted after the complete conversion of a number of characters, it may
18 need to save a state for processing the remaining characters. Such a
19 conversion state is needed for the sake of encodings such as ISO-2022
20 and UTF-7.
21
22 The initial state is the state at the beginning of conversion of a
23 string. There are two kinds of state: The one used by multibyte to
24 wide character conversion functions, such as mbsrtowcs(3), and the one
25 used by wide character to multibyte conversion functions, such as wcsr‐
26 tombs(3), but they both fit in a mbstate_t, and they both have the same
27 representation for an initial state.
28
29 For 8-bit encodings, all states are equivalent to the initial state.
30 For multibyte encodings like UTF-8, EUC-*, BIG5 or SJIS, the wide char‐
31 acter to multibyte conversion functions never produce non-initial
32 states, but the multibyte to wide-character conversion functions like
33 mbrtowc(3) do produce non-initial states when interrupted in the middle
34 of a character.
35
36 One possible way to create an mbstate_t in initial state is to set it
37 to zero:
38
39 mbstate_t state;
40 memset(&state,0,sizeof(mbstate_t));
41
42 On Linux, the following works as well, but might generate compiler
43 warnings:
44
45 mbstate_t state = { 0 };
46
47 The function mbsinit() tests whether *ps corresponds to an initial
48 state.
49
51 mbsinit() returns nonzero if *ps is an initial state, or if ps is a
52 NULL pointer. Otherwise it returns 0.
53
55 C99.
56
58 The behavior of mbsinit() depends on the LC_CTYPE category of the cur‐
59 rent locale.
60
62 mbsrtowcs(3), wcsrtombs(3)
63
65 This page is part of release 3.53 of the Linux man-pages project. A
66 description of the project, and information about reporting bugs, can
67 be found at http://www.kernel.org/doc/man-pages/.
68
69
70
71GNU 2000-11-20 MBSINIT(3)