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(), and the one
25       used by wide character to multibyte conversion functions, such as wcsr‐
26       tombs(),  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() 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         mbstate_t state;
39         memset(&state,0,sizeof(mbstate_t));
40       On Linux, the following works as  well,  but  might  generate  compiler
41       warnings:
42         mbstate_t state = { 0 };
43
44       The  function  mbsinit()  tests  whether  *ps corresponds to an initial
45       state.
46

RETURN VALUE

48       mbsinit() returns non-zero if *ps is an initial state, or if  ps  is  a
49       null pointer. Otherwise it returns 0.
50

CONFORMING TO

52       C99
53

SEE ALSO

55       mbsrtowcs(3), wcsrtombs(3)
56

NOTES

58       The behaviour of mbsinit() depends on the LC_CTYPE category of the cur‐
59       rent locale.
60
61
62
63GNU                               2000-11-20                        MBSINIT(3)
Impressum