.\" 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 .\" .\" About this Japanese page, please contact to JM Project .\" Translated Sat Oct 23 15:38:11 JST 1999 .\" by FUJIWARA Teruyoshi .\" .TH WCSRTOMBS 3 1999-07-25 "GNU" "Linux Programmer's Manual" .\"O .SH NAME .SH 名前 .\"O wcsrtombs \- convert a wide-character string to a multibyte string wcsrtombs \- ワイド文字文字列をマルチバイト文字列に変換する .\"O .SH SYNOPSIS .SH 書式 .nf .B #include .sp .BI "size_t wcsrtombs(char *" dest ", const wchar_t **" src , .BI " size_t " len ", mbstate_t *" ps ); .fi .\"O .SH DESCRIPTION .SH 説明 .\"O If \fIdest\fP is not a NULL pointer, .\"O the .\"O .BR wcsrtombs () .\"O function converts .\"O the wide-character string \fI*src\fP to a multibyte string starting at .\"O \fIdest\fP. .\"O At most \fIlen\fP bytes are written to \fIdest\fP. .\"O The shift state .\"O \fI*ps\fP is updated. .\"O The conversion is effectively performed by repeatedly .\"O calling .\"O .IR "wcrtomb(dest, *src, ps)" , .\"O as long as this call succeeds, .\"O and then incrementing \fIdest\fP by the .\"O number of bytes written and \fI*src\fP .\"O by one. .\"O The conversion can stop for three reasons: \fIdest\fP が NULL ポインタでなければ、 .BR wcsrtombs () 関数は ワイド文字文字列 \fI*src\fP を \fIdest\fP が指すマルチバイト文字列 に変換する。最大 \fIlen\fP バイトまでが \fIdest\fP に書き込まれる。 シフト状態 \fI*ps\fP は更新される。実際の効果としては、この変換は以下 の動作と同じになる: .IR "wcrtomb(dest, *src, ps)" を呼び、成功が返ったら、 \fIdest\fP を書き込んだバイト数だけ増やし、\fI*src\fP を 1 増やす。 そして、wcrtomb が成功を返す限りこれを繰り返す。 変換が止まる理由は 3 つ考えられる: .PP .\"O 1. A wide character has been encountered that can not be represented as a .\"O multibyte sequence (according to the current locale). .\"O In this case \fI*src\fP .\"O is left pointing to the invalid wide character, .\"O .I (size_t)\ \-1 .\"O is returned, .\"O and .\"O .I errno .\"O is set to \fBEILSEQ\fP. (現在のロケールに基づいて)マルチバイト列で表現できないワイド文字に 出会った場合。この場合は、\fI*src\fP は不正なワイド文字を指した状態になり、 .I (size_t)\ \-1 が返され、 .I errno に \fBEILSEQ\fP が設定される。 .PP .\"O 2. The length limit forces a stop. .\"O In this case \fI*src\fP is left pointing .\"O to the next wide character to be converted, .\"O and the number of bytes written to .\"O \fIdest\fP is returned. 2. 長さの制限により変換が止められた場合。この場合には、\fI*src\fP は次に 変換されるべきワイド文字列を指した状態になり、\fIdest\fP に書き込まれ たバイト数が返される。 .PP .\"O 3. The wide-character string has been completely converted, including the .\"O terminating L\(aq\\0\(aq (which has the side effect of bringing back \fI*ps\fP .\"O to the initial state). .\"O In this case \fI*src\fP is set to NULL, and the number .\"O of bytes written to \fIdest\fP, excluding the terminating \(aq\\0\(aq byte, is .\"O returned. 3. ワイド文字列が終端の L\(aq\\0\(aq (これには \fI*ps\fP を初期状態に戻すと いう副作用がある)も含めて全て変換された場合。この場合には \fI*src\fP に NULL が設定され、\fIdest\fP に書き込まれたバイト数が返される (終端の \(aq\\0\(aq は数えない)。 .PP .\"O If \fIdest\fP is NULL, \fIlen\fP is ignored, .\"O and the conversion proceeds as above, except that the converted bytes .\"O are not written out to memory, and that .\"O no length limit exists. \fIdest\fP が NULL ならば \fIlen\fP は無視されて前述のように変換が行わ れるが、変換されたバイトデータはメモリに書き出されない点と、出力先の長 さの制限がない点が異なる。 .PP .\"O In both of the above cases, .\"O if \fIps\fP is a NULL pointer, a static anonymous .\"O state only known to the wcsrtombs function is used instead. 上記のいずれの場合も、\fIps\fP が NULL ポインタならば、wcsnrtombs 関数 だけが知っている静的な匿名の状態がシフト状態の代わりに用いられる。 .PP .\"O The programmer must ensure that there is room for at least \fIlen\fP bytes .\"O at \fIdest\fP. プログラマは少なくとも \fIlen\fP バイトの領域を \fIdest\fP に確保しな ければならない。 .\"O .SH "RETURN VALUE" .SH 返り値 .\"O The .\"O .BR wcsrtombs () .\"O function returns .\"O the number of bytes that make up the .\"O converted part of multibyte sequence, .\"O not including the terminating null byte. .BR wcsrtombs () は、変換して得られたマルチバイト列のバイト数を返す。 これには終端の null バイトは含まれない。 .\"O If a wide character was encountered .\"O which could not be converted, .\"O .I (size_t)\ \-1 .\"O is returned, and .\"O .I errno .\"O set to \fBEILSEQ\fP. 変換できないワイド文字に出会った場合には .I (size_t)\ \-1 が返され、 .I errno に \fBEILSEQ\fP が設定される。 .\"O .SH "CONFORMING TO" .SH 準拠 C99. .\"O .SH NOTES .\"O The behavior of .\"O .BR wcsrtombs () .\"O depends on the .\"O .B LC_CTYPE .\"O category of the .\"O current locale. .BR wcsrtombs () の動作は現在のロケールの .B LC_CTYPE カテゴリに依存する。 .PP .\"O Passing NULL as \fIps\fP is not multithread safe. \fIps\fP に NULL を渡した際の動作はマルチスレッドセーフでない。 .\"O .SH "SEE ALSO" .SH 関連項目 .BR iconv (3), .BR wcsnrtombs (3), .BR wcstombs (3)