mbtowcのヘルプ・マニュアル
日本語 英語
mbtowc --help
man mbtowc
MBTOWC(3) Linux Programmer’s Manual MBTOWC(3)
名前
mbtowc - マルチバイト列をワイド文字に変換する
書式
#include
int mbtowc(wchar_t *pwc, const char *s, size_t n);
説明
こ の関数が用いられる場合、通常 s が NULL でなく pwc も NULL でない。こ
の場合は mbtowc() 関数は s から始まる最大 n バイトのマルチバイト文字 列
を 検査して、次の完全なマルチバイト文字を取り出し、それをワイド文字に変
換して *pwc に格納する。同時に mbtowc 関数のみが使用する内部状態を更 新
す る。s が '\0' 以外のバイトを指している場合は、s から消費するバイト数
を返す。 s が '\0' を指している場合には 0 を返す。
s から始まる n バイトが完全なマルチバイト文字を含んでいない場合や不正な
マ ルチバイト列を含んでいる場合には mbtowc() は -1 を返す。マルチバイト
文字列に冗長なシフトシーケンスが含まれていると n >= MB_CUR_MAX の場合も
このようなことが起こりえる。
s が NULL でなく pwc が NULL の場合は mbtowc() 関数は上記と同様に動作す
るが、変換したワイド文字はメモリには書き込まれない。
三番目の場合として s が NULL の場合は pwc と n は無視される。 mbtowc()
関 数のみが使用するシフト状態は初期状態に戻される。そして文字符号がシフ
ト状態に依存するならばゼロ以外を、文字符号が状態によらないならばゼロ を
返す。
返り値
s が NULL でなければ mbtowc() 関数は s から消費したバイト数を、s がナル
文字を指している場合はゼロを、変換に失敗した場合は -1 を返す。
s が NULL ならば mbtowc() 関数は文字符号がシフト状態に依存していれば ゼ
ロ以外を、状態によらなければゼロを返す。
準拠
C99.
注意
mbtowc() の動作は現在のロケールの LC_CTYPE カテゴリに依存している。
こ の関数はマルチスレッドでは安全ではない。 mbrtowc(3) 関数は同じ機能の
より良いインターフェースを提供する。
関連項目
MB_CUR_MAX(3), mbrtowc(3), mbstowcs(3)
GNU 2001-07-04 MBTOWC(3)
MBTOWC(3) Linux Programmer’s Manual MBTOWC(3)
NAME
mbtowc - convert a multibyte sequence to a wide character
SYNOPSIS
#include
int mbtowc(wchar_t *pwc, const char *s, size_t n);
DESCRIPTION
The main case for this function is when s is not NULL and pwc is not
NULL. In this case, the mbtowc() function inspects at most n bytes of
the multibyte string starting at s, extracts the next complete multi-
byte character, converts it to a wide character and stores it at *pwc.
It updates an internal shift state only known to the mbtowc function.
If s does not point to a '\0' byte, it returns the number of bytes that
were consumed from s, otherwise it returns 0.
If the n bytes starting at s do not contain a complete multibyte char-
acter, or if they contain an invalid multibyte sequence, mbtowc()
returns -1. This can happen even if n >= MB_CUR_MAX, if the multibyte
string contains redundant shift sequences.
A different case is when s is not NULL but pwc is NULL. In this case
the mbtowc() function behaves as above, except that it does not store
the converted wide character in memory.
A third case is when s is NULL. In this case, pwc and n are ignored.
The mbtowc() function resets the shift state, only known to this func-
tion, to the initial state, and returns non-zero if the encoding has
nontrivial shift state, or zero if the encoding is stateless.
RETURN VALUE
If s is not NULL, the mbtowc() function returns the number of consumed
bytes starting at s, or 0 if s points to a null byte, or -1 upon fail-
ure.
If s is NULL, the mbtowc() function returns non-zero if the encoding
has nontrivial shift state, or zero if the encoding is stateless.
CONFORMING TO
C99.
NOTES
The behavior of mbtowc() depends on the LC_CTYPE category of the cur-
rent locale.
This function is not multithread safe. The function mbrtowc(3) pro-
vides a better interface to the same functionality.
SEE ALSO
MB_CUR_MAX(3), mbrtowc(3), mbstowcs(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 2001-07-04 MBTOWC(3)