名前空間
変種
操作

std::wcstombs

提供: cppreference.com
< cpp‎ | string‎ | multibyte

 
 
ストリングスライブラリ
NULLで終わる文字列
Original:
Null-terminated strings
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
バイト文字列
文字列をマルチバイト
ワイド文字列
クラス
Original:
Classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_string
char_traits
 
NULLで終わるマルチバイト文字列
マルチバイト/ワイドコンバージョン
Original:
Wide/multibyte conversions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
mbsinit
タイプ
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
mbstate_t
 
Defined in header <cstdlib>
std::size_t wcstombs( char* dst, const wchar_t* src, std::size_t len)
最初の要素は初期シフト状態で始まるその狭いマルチバイト表現にsrcによって指された配列のワイド文字のシーケンスに変換します。変換された文字はdstが指すchar型の配列の連続する要素に格納されています。 lenバイト以上は、コピー先の配列に書き込まれません.
Original:
Converts a sequence of wide characters from the array whose first element is pointed to by src to its narrow multibyte representation that begins in the initial shift state. Converted characters are stored in the successive elements of the char array pointed to by dst. No more than len bytes are written to the destination array.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
各文字は、wctomb関数の変換状態が影響を受けないことを除けば、std::wctombへの呼び出しと同じように変換されます。次の場合、変換は終了します
Original:
Each character is converted as if by a call to std::wctomb, except that the wctomb's conversion state is unaffected. The conversion stops if:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • ヌル文字が変換されて格納されていた.
    Original:
    The null character was converted and stored.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • wchar_tは、現在のCロケールで有効な文字に対応していないことが判明した.
    Original:
    A wchar_t was found that does not correspond to a valid character in the current C locale.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 格納する次のマルチバイト文字がlenを超えてしまう.
    Original:
    The next multibyte character to be stored would exceed len.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

目次

[編集] ノート

それは文字列を使用して処理するときに、ほとんどの実装では、この関数は、型std::mbstate_tのグローバルな静的オブジェクトを更新し、2つのスレッドで同時に呼び出すことはできません、std::wcsrtombsは、そのような場合に使用されるべき.
Original:
In most implementations, this function updates a global static object of type std::mbstate_t as it processes through the string, and cannot be called simultaneously by two threads, std::wcsrtombs should be used in such cases.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
POSIXは、一般的な拡張子を指定します。dstがNULLポインターである場合、この関数は、変換された場合、dstに書き込まれるバイト数を返します。同様の現象がstd::wcsrtombsするための標準規格です.
Original:
POSIX specifies a common extension: if dst is a null pointer, this function returns the number of bytes that would be written to dst, if converted. Similar behavior is standard for std::wcsrtombs.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] パラメータ

dst -
マルチバイト文字が格納される狭い文字配列へのポインタ
Original:
pointer to narrow character array where the multibyte character will be stored
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
src -
変換するNULLで終わるワイド文字列の最初の要素へのポインタ
Original:
pointer to the first element of a null-terminated wide string to convert
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
len -
dstが指す配列内の使用可能なバイト数
Original:
number of byte available in the array pointed to by dst
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 値を返します

成功した場合、最初の要素が'\0'によって指された文字配列に書き込まれたバイト数を(任意のシフトシーケンスを含むが、終端dstを除く)を返します。.
Original:
On success, returns the number of bytes (including any shift sequences, but excluding the terminating '\0') written to the character array whose first element is pointed to by dst.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
変換エラー(不正なワイド文字が検出された場合)に、static_cast<std::size_t>(-1)返し.
Original:
On conversion error (if invalid wide character was encountered), returns static_cast<std::size_t>(-1).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集]

#include <iostream>
#include <clocale>
#include <cstdlib>
 
int main()
{
    std::setlocale(LC_ALL, "en_US.utf8");
    // UTF-8 narrow multibyte encoding
    const wchar_t* wstr = L"z\u00df\u6c34\U0001d10b"; // or L"zß水𝄋"
    char mbstr[11];
    std::wcstombs(mbstr, wstr, 11);
    std::cout << "multibyte string: " << mbstr << '\n';
}

Output:

multibyte string: zß水𝄋

[編集] も参照してください

ナローマルチバイト文字列、所定の状態にワイド文字列に変換します
Original:
converts a wide string to narrow multibyte character string, given state
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(機能) [edit]
ワイド文字列へのナローマルチバイト文字列に変換します
Original:
converts a narrow multibyte character string to wide string
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(機能) [edit]
[仮想]
そのようなファイルに書き込むときのように、internTからexternTに文字列を変換します
Original:
converts a string from internT to externT, such as when writing to file
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(仮想protectedメンバ関数of std::codecvt) [edit]
C documentation for wcstombs