|
Packit |
7cfc04 |
.\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" %%%LICENSE_START(GPLv2+_DOC_ONEPARA)
|
|
Packit |
7cfc04 |
.\" This is free documentation; you can redistribute it and/or
|
|
Packit |
7cfc04 |
.\" modify it under the terms of the GNU General Public License as
|
|
Packit |
7cfc04 |
.\" published by the Free Software Foundation; either version 2 of
|
|
Packit |
7cfc04 |
.\" the License, or (at your option) any later version.
|
|
Packit |
7cfc04 |
.\" %%%LICENSE_END
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" References consulted:
|
|
Packit |
7cfc04 |
.\" GNU glibc-2 source code and manual
|
|
Packit |
7cfc04 |
.\" Dinkumware C library reference http://www.dinkumware.com/
|
|
Packit |
7cfc04 |
.\" OpenGroup's Single UNIX specification http://www.UNIX-systems.org/online.html
|
|
Packit |
7cfc04 |
.\" ISO/IEC 9899:1999
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.TH MBSINIT 3 2016-10-08 "GNU" "Linux Programmer's Manual"
|
|
Packit |
7cfc04 |
.SH NAME
|
|
Packit |
7cfc04 |
mbsinit \- test for initial shift state
|
|
Packit |
7cfc04 |
.SH SYNOPSIS
|
|
Packit |
7cfc04 |
.nf
|
|
Packit |
7cfc04 |
.B #include <wchar.h>
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
.BI "int mbsinit(const mbstate_t *" ps );
|
|
Packit |
7cfc04 |
.fi
|
|
Packit |
7cfc04 |
.SH DESCRIPTION
|
|
Packit |
7cfc04 |
Character conversion between the multibyte representation and the wide
|
|
Packit |
7cfc04 |
character representation uses conversion state, of type
|
|
Packit |
7cfc04 |
.IR mbstate_t .
|
|
Packit |
7cfc04 |
Conversion of a string uses a finite-state machine; when it is interrupted
|
|
Packit |
7cfc04 |
after the complete conversion of a number of characters, it may need to
|
|
Packit |
7cfc04 |
save a state for processing the remaining characters.
|
|
Packit |
7cfc04 |
Such a conversion
|
|
Packit |
7cfc04 |
state is needed for the sake of encodings such as ISO-2022 and UTF-7.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
The initial state is the state at the beginning of conversion of a string.
|
|
Packit |
7cfc04 |
There are two kinds of state: the one used by multibyte to wide character
|
|
Packit |
7cfc04 |
conversion functions, such as
|
|
Packit |
7cfc04 |
.BR mbsrtowcs (3),
|
|
Packit |
7cfc04 |
and the one used by wide
|
|
Packit |
7cfc04 |
character to multibyte conversion functions, such as
|
|
Packit |
7cfc04 |
.BR wcsrtombs (3),
|
|
Packit |
7cfc04 |
but they both fit in a
|
|
Packit |
7cfc04 |
.IR mbstate_t ,
|
|
Packit |
7cfc04 |
and they both have the same
|
|
Packit |
7cfc04 |
representation for an initial state.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
For 8-bit encodings, all states are equivalent to the initial state.
|
|
Packit |
7cfc04 |
For multibyte encodings like UTF-8, EUC-*, BIG5 or SJIS, the wide character
|
|
Packit |
7cfc04 |
to multibyte conversion functions never produce non-initial states, but the
|
|
Packit |
7cfc04 |
multibyte to wide-character conversion functions like
|
|
Packit |
7cfc04 |
.BR mbrtowc (3)
|
|
Packit |
7cfc04 |
do
|
|
Packit |
7cfc04 |
produce non-initial states when interrupted in the middle of a character.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
One possible way to create an
|
|
Packit |
7cfc04 |
.I mbstate_t
|
|
Packit |
7cfc04 |
in initial state is to set it to zero:
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
.in +4n
|
|
Packit |
7cfc04 |
.EX
|
|
Packit |
7cfc04 |
mbstate_t state;
|
|
Packit |
7cfc04 |
memset(&state,0,sizeof(mbstate_t));
|
|
Packit |
7cfc04 |
.EE
|
|
Packit |
7cfc04 |
.in
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
On Linux, the following works as well, but might generate compiler warnings:
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
.in +4n
|
|
Packit |
7cfc04 |
.EX
|
|
Packit |
7cfc04 |
mbstate_t state = { 0 };
|
|
Packit |
7cfc04 |
.EE
|
|
Packit |
7cfc04 |
.in
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
The function
|
|
Packit |
7cfc04 |
.BR mbsinit ()
|
|
Packit |
7cfc04 |
tests whether
|
|
Packit |
7cfc04 |
.I *ps
|
|
Packit |
7cfc04 |
corresponds to an
|
|
Packit |
7cfc04 |
initial state.
|
|
Packit |
7cfc04 |
.SH RETURN VALUE
|
|
Packit |
7cfc04 |
.BR mbsinit ()
|
|
Packit |
7cfc04 |
returns nonzero if
|
|
Packit |
7cfc04 |
.I *ps
|
|
Packit |
7cfc04 |
is an initial state, or if
|
|
Packit |
7cfc04 |
.I ps
|
|
Packit |
7cfc04 |
is NULL.
|
|
Packit |
7cfc04 |
Otherwise, it returns 0.
|
|
Packit |
7cfc04 |
.SH ATTRIBUTES
|
|
Packit |
7cfc04 |
For an explanation of the terms used in this section, see
|
|
Packit |
7cfc04 |
.BR attributes (7).
|
|
Packit |
7cfc04 |
.TS
|
|
Packit |
7cfc04 |
allbox;
|
|
Packit |
7cfc04 |
lb lb lb
|
|
Packit |
7cfc04 |
l l l.
|
|
Packit |
7cfc04 |
Interface Attribute Value
|
|
Packit |
7cfc04 |
T{
|
|
Packit |
7cfc04 |
.BR mbsinit ()
|
|
Packit |
7cfc04 |
T} Thread safety MT-Safe
|
|
Packit |
7cfc04 |
.TE
|
|
Packit |
7cfc04 |
.SH CONFORMING TO
|
|
Packit |
7cfc04 |
POSIX.1-2001, POSIX.1-2008, C99.
|
|
Packit |
7cfc04 |
.SH NOTES
|
|
Packit |
7cfc04 |
The behavior of
|
|
Packit |
7cfc04 |
.BR mbsinit ()
|
|
Packit |
7cfc04 |
depends on the
|
|
Packit |
7cfc04 |
.B LC_CTYPE
|
|
Packit |
7cfc04 |
category of the
|
|
Packit |
7cfc04 |
current locale.
|
|
Packit |
7cfc04 |
.SH SEE ALSO
|
|
Packit |
7cfc04 |
.BR mbrlen (3),
|
|
Packit |
7cfc04 |
.BR mbrtowc (3),
|
|
Packit |
7cfc04 |
.BR mbsrtowcs (3),
|
|
Packit |
7cfc04 |
.BR wcrtomb (3),
|
|
Packit |
7cfc04 |
.BR wcsrtombs (3)
|
|
Packit |
7cfc04 |
.SH COLOPHON
|
|
Packit |
7cfc04 |
This page is part of release 4.15 of the Linux
|
|
Packit |
7cfc04 |
.I man-pages
|
|
Packit |
7cfc04 |
project.
|
|
Packit |
7cfc04 |
A description of the project,
|
|
Packit |
7cfc04 |
information about reporting bugs,
|
|
Packit |
7cfc04 |
and the latest version of this page,
|
|
Packit |
7cfc04 |
can be found at
|
|
Packit |
7cfc04 |
\%https://www.kernel.org/doc/man\-pages/.
|