.\" Copyright (c) Bruno Haible .\" .\" This is free documentation; you can redistribute it and/or .\" modify it under the terms of the GNU General Public License as .\" published by the Free Software Foundation; either version 2 of .\" the License, or (at your option) any later version. .\" .\" References consulted: .\" GNU glibc-2 source code and manual .\" Dinkumware C library reference http://www.dinkumware.com/ .\" OpenGroup's Single UNIX specification .\" http://www.UNIX-systems.org/online.html .\" ISO/IEC 9899:1999 .\" .\" Japanese Version Copyright (c) 1999 HANATAKA Shinya .\" all rights reserved. .\" Translated Tue Jan 11 00:56:16 JST 2000 .\" by HANATAKA Shinya .\" Updated Thu Dec 13 JST 2001 by Kentaro Shirakata .\" .TH MBRTOWC 3 2001-11-22 "GNU" "Linux Programmer's Manual" .\"O .SH NAME .SH 名前 .\"O mbrtowc \- convert a multibyte sequence to a wide character mbrtowc \- マルチバイト列をワイド文字に変換する .\"O .SH SYNOPSIS .SH 書式 .nf .B #include .sp .BI "size_t mbrtowc(wchar_t *" pwc ", const char *" s ", size_t " n \ ", mbstate_t *" ps ); .fi .\"O .SH DESCRIPTION .SH 説明 .\"O The main case for this function is when \fIs\fP is not NULL and \fIpwc\fP is .\"O not NULL. .\"O In this case, the .\"O .BR mbrtowc () .\"O function inspects at most \fIn\fP .\"O bytes of the multibyte string starting at \fIs\fP, extracts the next complete .\"O multibyte character, converts it to a wide character and stores it at .\"O \fI*pwc\fP. .\"O It updates the shift state \fI*ps\fP. .\"O If the converted wide .\"O character is not L\(aq\\0\(aq, it returns the number of bytes that were consumed .\"O from \fIs\fP. .\"O If the converted wide character is L\(aq\\0\(aq, it resets the shift .\"O state \fI*ps\fP to the initial state and returns 0. この関数が用いられる場合、通常 \fIs\fP が NULL でなく \fIpwc\fP も NULL で ない。この場合は、 .BR mbrtowc () 関数は \fIs\fP から始まる最大 \fIn\fP バイトの マルチバイト文字を検査して、次の完全なマルチバイト文字列を取り出し、 それをワイド文字に変換して \fI*pwc\fP に格納する。 同時にシフト状態 \fI*ps\fP を更新する。変換したワイド文字が L\(aq\\0\(aq で なければ、\fIs\fP から消費するバイト数を返す。 変換したワイド文字が L\(aq\\0\(aq の場合にはシフト状態 \fI*ps\fP を 初期状態に戻して 0 を返す。 .PP .\"O If the \fIn\fP bytes starting at \fIs\fP do not contain a complete multibyte .\"O character, .\"O .BR mbrtowc () .\"O returns \fI(size_t)\ \-2\fP. .\"O This can happen even if .\"O \fIn\fP >= \fIMB_CUR_MAX\fP, if the multibyte string contains redundant shift .\"O sequences. \fIs\fP から始まる \fIn\fP バイトが完全なマルチバイト文字を含んでいない 場合には、 .BR mbrtowc () は \fI(size_t)\ \-2\fP を返す。 マルチバイト文字列に冗長なシフトシーケンスが含まれていると、 \fIn\fP >= \fIMB_CUR_MAX\fP の時にもこのようなことが起こりえる。 .PP .\"O If the multibyte string starting at \fIs\fP contains an invalid multibyte .\"O sequence before the next complete character, .\"O .BR mbrtowc () .\"O returns .\"O \fI(size_t)\ \-1\fP and sets \fIerrno\fP to \fBEILSEQ\fP. .\"O In this case, .\"O the effects on \fI*ps\fP are undefined. \fIs\fP から始まるマルチバイト文字列が、次の完全な文字の前に 不正なマルチバイト列を含んでいる場合には、 .BR mbrtowc () は \fI(size_t)\ \-1\fP を返し、\fIerrno\fP に \fBEILSEQ\fP を設定する。 この場合は \fI*ps\fP への影響は未定義である。 .PP .\"O A different case is when \fIs\fP is not NULL but \fIpwc\fP is NULL. .\"O In this .\"O case the .\"O .BR mbrtowc () .\"O function behaves as above, except that it does not .\"O store the converted wide character in memory. \fIs\fP が NULL でなく \fIpwc\fP が NULL の場合は .BR mbrtowc () 関数は 上記と同様に動作するが、変換したワイド文字はメモリには書き込まれない。 .PP .\"O A third case is when \fIs\fP is NULL. .\"O In this case, \fIpwc\fP and \fIn\fP are .\"O ignored. .\"O If the conversion state represented by \fI*ps\fP denotes an .\"O incomplete multibyte character conversion, the .\"O .BR mbrtowc () .\"O function .\"O returns \fI(size_t)\ \-1\fP, sets \fIerrno\fP to \fBEILSEQ\fP, and .\"O leaves \fI*ps\fP in an undefined state. .\"O Otherwise, the .\"O .BR mbrtowc () .\"O function puts \fI*ps\fP in the initial state and returns 0. 三番目の場合として \fIs\fP が NULL の場合、 \fIpwc\fP と \fIn\fP は 無視される。 \fI*ps\fP が表現する変換状態が不完全なマルチバイト文字変換を示している場合は、 .BR mbrtowc () 関数は \fI(size_t)\ \-1\fP を返し、 \fIerrno\fP に \fBEILSEQ\fP をセットし、 \fI*ps\fP は未定義状態のままにする。 さもなければ、 .BR mbrtowc () 関数は \fI*ps\fP を初期状態にして 0 を返す。 .PP .\"O In all of the above cases, if \fIps\fP is a NULL pointer, a static anonymous .\"O state only known to the mbrtowc function is used instead. 上記の全ての場合において、\fIps\fP が NULL ポインターならば代わりに mbrtowc 関数のみが使用する静的で名前のない状態が使用される。 .\"O Otherwise, \fI*ps\fP must be a valid \fImbstate_t\fP object. さもなければ、\fI*ps\fP は有効な \fImbstate_t\fP オブジェクトで なければならない。 .\"O An \fImbstate_t\fP object \fIa\fP can be initialized to the initial state .\"O by zeroing it, for example using \fImbstate_t\fP オブジェクトである \fIa\fP はゼロで埋めることによって 初期状態に初期化できる。以下に例を示す。 .sp .in +4n memset(&a, 0, sizeof(a)); .in .\"O .SH "RETURN VALUE" .SH 返り値 .\"O The .\"O .BR mbrtowc () .\"O function returns the number of bytes parsed from the .\"O multibyte sequence starting at \fIs\fP, if a non-L\(aq\\0\(aq wide character .\"O was recognized. L\(aq\\0\(aq 以外のワイド文字を認識した場合には .BR mbrtowc () 関数は \fIs\fP から始まるマルチバイト列から解析したバイト数を返す。 .\"O It returns 0, if a L\(aq\\0\(aq wide character was recognized. .\"O It returns .\"O .I (size_t)\ \-1 .\"O and sets \fIerrno\fP to \fBEILSEQ\fP, if an invalid multibyte sequence was .\"O encountered. .\"O It returns \fI(size_t)\ \-2\fP if it couldn't parse a complete multibyte .\"O character, meaning that \fIn\fP should be increased. L\(aq\\0\(aq ワイド文字を認識した場合には 0 を返す。 不正なマルチバイト列に遭遇した場合には .I (size_t)\ \-1 を返し、 \fIerrno\fP に \fBEILSEQ\fP を設定する。完全なマルチバイト文字を 解析できなかった場合には .I (size_t)\ \-2 を返し \fIn\fP を増加させる必要があることを示す。 .\"O .SH "CONFORMING TO" .SH 準拠 C99. .\"O .SH NOTES .SH 注意 .\"O The behavior of .\"O .BR mbrtowc () .\"O depends on the .\"O .B LC_CTYPE .\"O category of the .\"O current locale. .BR mbrtowc () の動作は現在のロケールの .B LC_CTYPE カテゴリに依存している。 .\"O .SH "SEE ALSO" .SH 関連項目 .BR mbsrtowcs (3)