mbstowcsのヘルプ・マニュアル
日本語 英語
mbstowcs --help
man mbstowcs
MBSTOWCS(3) Linux Programmer’s Manual MBSTOWCS(3)
名前
mbstowcs - マルチバイト文字列をワイド文字列に変換する
書式
#include
size_t mbstowcs(wchar_t *dest, const char *src, size_t n);
説明
dest が NULL ポインターでなければ mbstowcs() 関数はマルチバイト文字列
*src を dest から始まるワイド文字列に変換する。dest には最大で n 文字の
ワ イド文字が書き込まれる。変換は初期状態で開始され、以下の三つのいずれ
かの条件で停止する:
1. 不正なマルチバイト列に遭遇した。この場合には (size_t) -1 を返す。
2. n 文字の L'\0' 以外のワイド文字を dest に格納した場合。この 場 合 は
*src が次に変換されるマルチバイト列を指すようにして、 dest に書き込
まれたワイド文字の数を返す。しかしこの指している場所のシフト状態は失
われる。
3. マルチバイト文字列が終端の '\0' まで含めて完全に変換された場合。この
場合は終端の L'\0' 文字を除いて dest に書き込まれた文字数を返す。
プログラマーは dest に最低でも n ワイド文字を書き込むことができる空間が
あることを保証しなければならない。
dest が NULL の場合、n は無視され、上記と同様の変換が行われるが、変換さ
れたワイド文字はメモリに書き込まれず、変換先の上限が存在しない。
上記の 2. の 場 合 を 避 け る た め に プ ロ グ ラ マ ー は n が
mbstowcs(NULL,src,0)+1 以上であることを保証すべきである。
返り値
mbstowcs() 関数はワイド文字列に変換完了したワイド文字の数を返す。終端の
ナルワイド文字は含まない。不正なマルチバイト列に遭 遇 し た 場 合 に は
(size_t) -1 を返す。
準拠
C99.
注意
mbstowcs() の動作は現在のロケールの LC_CTYPE カテゴリに依存している。
mbsrtowcs(3) 関数は同じ機能のより良いインターフェースを提供する。
関連項目
mbsrtowcs(3)
GNU 1999-07-25 MBSTOWCS(3)
MBSTOWCS(3) Linux Programmer’s Manual MBSTOWCS(3)
NAME
mbstowcs - convert a multibyte string to a wide-character string
SYNOPSIS
#include
size_t mbstowcs(wchar_t *dest, const char *src, size_t n);
DESCRIPTION
If dest is not a NULL pointer, the mbstowcs() function converts the
multibyte string src to a wide-character string starting at dest. At
most n wide characters are written to dest. The conversion starts in
the initial state. The conversion can stop for three reasons:
1. An invalid multibyte sequence has been encountered. In this case
(size_t) -1 is returned.
2. n non-L'\0' wide characters have been stored at dest. In this case
the number of wide characters written to dest is returned, but the
shift state at this point is lost.
3. The multibyte string has been completely converted, including the
terminating '\0'. In this case the number of wide characters writ-
ten to dest, excluding the terminating L'\0' character, is returned.
The programmer must ensure that there is room for at least n wide char-
acters at dest.
If dest is NULL, n is ignored, and the conversion proceeds as above,
except that the converted wide characters are not written out to mem-
ory, 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 mbstowcs(NULL,src,0)+1.
RETURN VALUE
The mbstowcs() function returns the number of wide characters that make
up the converted part of the wide-character string, not including the
terminating null wide character. If an invalid multibyte sequence was
encountered, (size_t) -1 is returned.
CONFORMING TO
C99.
NOTES
The behavior of mbstowcs() depends on the LC_CTYPE category of the cur-
rent locale.
The function mbsrtowcs(3) provides a better interface to the same func-
tionality.
SEE ALSO
mbsrtowcs(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 MBSTOWCS(3)