mbsinitのヘルプ・マニュアル
日本語 英語
mbsinit --help
man mbsinit
MBSINIT(3) Linux Programmer’s Manual MBSINIT(3)
名前
mbsinit - 初期シフト状態かどうかを検査する
書式
#include
int mbsinit(const mbstate_t *ps);
説明
文 字をマルチバイト表現とワイド文字表現の間で変換する場合には mbstate_t
型の変換状態を使用する。文字列の変換は有限状態マシンを使用する。いく ら
か の文字の変換を完了した後に、残りの文字を処理するために状態を保存して
おく必要があるかもしれない。このような変換状態は ISO-2022 や UTF-7 のよ
うな符号を扱うのに必要とされる。
初 期状態とは文字列の変換を開始する時の状態である。状態には二種類が存在
し、一つは mbsrtowcs(3) のようなマルチバイトをワイド文字に変換する関 数
で 使用される。もう一つは wcsrtombs(3) のようなワイド文字をマルチバイト
に変換する関数で使用される。しかし両方とも mbstate_t に格納され、初期状
態として同じ表現を持つ。
8 ビ ット符号においては全ての状態は初期状態と等価である。 UTF-8, EUC-*,
BIG5, SJIS のような多バイト符号においてワイド文字から多バイト文字への変
換 関数は非初期状態にはならない。しかし mbrtowc(3) のような多バイト文字
からワイド文字への変換関数では文字の解釈の途中で非初期状態となる場合 が
ある。
初期状態の mbstate_t を作成する方法の一つは、それをゼロに設定することで
ある:
mbstate_t state;
memset(&state,0,sizeof(mbstate_t));
Linux においては以下の方法でも同様であるが、コンパイラーの警告が生成 さ
れるかもしれない。
mbstate_t state = { 0 };
mbsinit() は *ps が初期状態に一致するかどうかを検査する。
返り値
mbsinit() は *ps が初期状態の場合や NULL ポインターの場合にはゼロ以外を
返す。それ以外の場合にはゼロを返す。
準拠
C99.
注意
mbsinit() の動作は現在のロケールの LC_CTYPE カテゴリに依存している。
関連項目
mbsrtowcs(3), wcsrtombs(3)
GNU 2000-11-20 MBSINIT(3)
MBSINIT(3) Linux Programmer’s Manual MBSINIT(3)
NAME
mbsinit - test for initial shift state
SYNOPSIS
#include
int mbsinit(const mbstate_t *ps);
DESCRIPTION
Character conversion between the multibyte representation and the wide
character representation uses conversion state, of type mbstate_t.
Conversion of a string uses a finite-state machine; when it is inter-
rupted after the complete conversion of a number of characters, it may
need to save a state for processing the remaining characters. Such a
conversion state is needed for the sake of encodings such as ISO-2022
and UTF-7.
The initial state is the state at the beginning of conversion of a
string. There are two kinds of state: The one used by multibyte to
wide character conversion functions, such as mbsrtowcs(3), and the one
used by wide character to multibyte conversion functions, such as wcsr-
tombs(3), but they both fit in a mbstate_t, and they both have the same
representation for an initial state.
For 8-bit encodings, all states are equivalent to the initial state.
For multibyte encodings like UTF-8, EUC-*, BIG5 or SJIS, the wide char-
acter to multibyte conversion functions never produce non-initial
states, but the multibyte to wide-character conversion functions like
mbrtowc(3) do produce non-initial states when interrupted in the middle
of a character.
One possible way to create an mbstate_t in initial state is to set it
to zero:
mbstate_t state;
memset(&state,0,sizeof(mbstate_t));
On Linux, the following works as well, but might generate compiler
warnings:
mbstate_t state = { 0 };
The function mbsinit() tests whether *ps corresponds to an initial
state.
RETURN VALUE
mbsinit() returns non-zero if *ps is an initial state, or if ps is a
null pointer. Otherwise it returns 0.
CONFORMING TO
C99.
NOTES
The behavior of mbsinit() depends on the LC_CTYPE category of the cur-
rent locale.
SEE ALSO
mbsrtowcs(3), wcsrtombs(3)
COLOPHON
This page is part of release 3.22 of the Linux man-pages project. A
description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
GNU 2000-11-20 MBSINIT(3)