1MBSINIT(3)                 Linux Programmer's Manual                MBSINIT(3)
2
3
4

NAME

6       mbsinit - test for initial shift state
7

SYNOPSIS

9       #include <wchar.h>
10
11       int mbsinit(const mbstate_t *ps);
12

DESCRIPTION

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

RETURN VALUE

51       mbsinit() returns nonzero if *ps is an initial state, or if ps is NULL.
52       Otherwise, it returns 0.
53

ATTRIBUTES

55       For   an   explanation   of   the  terms  used  in  this  section,  see
56       attributes(7).
57
58       ┌──────────┬───────────────┬─────────┐
59Interface Attribute     Value   
60       ├──────────┼───────────────┼─────────┤
61mbsinit() │ Thread safety │ MT-Safe │
62       └──────────┴───────────────┴─────────┘

CONFORMING TO

64       POSIX.1-2001, POSIX.1-2008, C99.
65

NOTES

67       The behavior of mbsinit() depends on the LC_CTYPE category of the  cur‐
68       rent locale.
69

SEE ALSO

71       mbrlen(3), mbrtowc(3), mbsrtowcs(3), wcrtomb(3), wcsrtombs(3)
72

COLOPHON

74       This  page  is  part of release 5.07 of the Linux man-pages project.  A
75       description of the project, information about reporting bugs,  and  the
76       latest     version     of     this    page,    can    be    found    at
77       https://www.kernel.org/doc/man-pages/.
78
79
80
81GNU                               2016-10-08                        MBSINIT(3)
Impressum