wcstombsのヘルプ・マニュアル
日本語 英語
wcstombs --help
man wcstombs
WCSTOMBS(3) Linux Programmer’s Manual WCSTOMBS(3)
名前
wcstombs - ワイド文字列をマルチバイト文字列に変換する
書式
#include
size_t wcstombs(char *dest, const wchar_t *src, size_t n);
説明
dest が NULL ポインタでない場合、 wcstombs() 関数はワイド文字列 src を
dest から始まるマルチバイト文字列に変換する。dest には最大で n バイトが
書き込まれる。変換は初期状態で開始される。変換は以下の3つの理由により停
止する。
1. (現在のロケールにおける)マルチバイト列で表現できないワイド文字に遭遇
した場合。この場合には (size_t) -1 が返される。
2. 長さ制限によって強制停止させられた場合。この場合には dest に書き込ま
れたバイト数が返される。しかしこの時点でのシフト状態は失われる。
3. ワイド文字列が終端の L'\0' を含めて完全に変換された場合。この場合 に
は 変換は初期状態で終り、終端の '\0' バイトを除いて dest に書き込まれた
バイト数を返す。
プログラマーは dest に最低でも n バイトの空きがあることを保証しなければ
ならない。
dest が NULL の場合、n は無視される。上記と同様に変換が行なわれるが変換
結果のバイト列はメモリには書き込まれない。また長さの上限が存在しない。
上記の 2. の 場 合 を 避 け る た め に 、 プ ロ グ ラ マ ー は n が
wcstombs(NULL,src,0)+1 以上であることを保証しなければならない。
返り値
wcstombs() 関数は生成したマルチバイト列のバイト数を返す。終端のナル文字
は含まない。もし変換できないワイド文字に遭遇した場合には (size_t) -1 を
返す。
準拠
C99.
注意
wcstombs() の動作は現在のロケールの LC_CTYPE カテゴリに依存している。
wcsrtombs() 関数は同じ機能のためのスレッド・セーフなインターフェースを
提供する。
関連項目
wcsrtombs(3)
GNU 1999-07-25 WCSTOMBS(3)
WCSTOMBS(3) Linux Programmer’s Manual WCSTOMBS(3)
NAME
wcstombs - convert a wide-character string to a multibyte string
SYNOPSIS
#include
size_t wcstombs(char *dest, const wchar_t *src, size_t n);
DESCRIPTION
If dest is not a NULL pointer, the wcstombs() function converts the
wide-character string src to a multibyte string starting at dest. At
most n bytes are written to dest. The conversion starts in the initial
state. The conversion can stop for three reasons:
1. A wide character has been encountered that can not be represented as
a multibyte sequence (according to the current locale). In this case
(size_t) -1 is returned.
2. The length limit forces a stop. In this case the number of bytes
written to dest is returned, but the shift state at this point is lost.
3. The wide-character string has been completely converted, including
the terminating L'\0'. In this case the conversion ends in the initial
state. The number of bytes written to dest, excluding the terminating
'\0' byte, is returned.
The programmer must ensure that there is room for at least n bytes at
dest.
If dest is NULL, n is ignored, and the conversion proceeds as above,
except that the converted bytes are not written out to memory, and that
no length limit exists.
In order to avoid the case 2 above, the programmer should make sure n
is greater or equal to wcstombs(NULL,src,0)+1.
RETURN VALUE
The wcstombs() function returns the number of bytes that make up the
converted part of multibyte sequence, not including the terminating
null byte. If a wide character was encountered which could not be con-
verted, (size_t) -1 is returned.
CONFORMING TO
C99.
NOTES
The behavior of wcstombs() depends on the LC_CTYPE category of the cur-
rent locale.
The function wcsrtombs(3) provides a thread safe interface to the same
functionality.
SEE ALSO
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 1999-07-25 WCSTOMBS(3)