名前空間
変種
操作

std::wcrtomb

提供: 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 <cwchar>
std::size_t wcrtomb( char* s, wchar_t wc, std::mbstate_t* ps );
その狭いマルチバイト表現にワイド文字を変換.
Original:
Converts a wide character to its narrow multibyte representation.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
sがNULLポインタでない場合、この関数はwc(任意のシフトシーケンスを含む)のマルチバイト文字表現を格納するのに必要なバイト数を決定し、その最初の要素sによって指された文字配列にマルチバイト文字表現を格納します。最もMB_CUR_MAXバイトに、この関数によって記述することができ.
Original:
If s is not a null pointer, the function determines the number of bytes necessary to store the multibyte character representation of wc (including any shift sequences), and stores the multibyte character representation in the character array whose first element is pointed to by s. At most MB_CUR_MAX bytes can be written by this function.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
sがNULLポインターである場合、コールは、いくつかの内部バッファstd::wcrtomb(buf, L'\0', ps)ためbufと同等です.
Original:
If s is a null pointer, the call is equivalent to std::wcrtomb(buf, L'\0', ps) for some internal buffer buf.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
wcが初期シフト状態と変換状態パラメータL'\0'を回復させるために必要なシフトシーケンスによって先行nullワイド文字の*ps、NULLバイトが格納されている、ある場合は初期シフト状態を表すために更新され.
Original:
If wc is the null wide character L'\0', a null byte is stored, preceded by any shift sequence necessary to restore the initial shift state and the conversion state parameter *ps is updated to represent the initial shift state.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

目次

[編集] パラメータ

s -
マルチバイト文字が格納される狭い文字配列へのポインタ
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.
wc -
変換するワイド文字
Original:
the wide character to convert
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ps -
マルチバイト文字列を解釈する際に使用される変換状態オブジェクトへのポインタ
Original:
pointer to the conversion state object used when interpreting the multibyte string
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 値を返します

成功した場合、最初の要素がsによって指された文字配列に書き込まれたバイト数を(任意のシフトシーケンスを含む)を返します。.
Original:
On success, returns the number of bytes (including any shift sequences) written to the character array whose first element is pointed to by s.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
失敗した場合に(もしwc有効なワイド文字ではありません)、返品static_cast<std::size_t>(-1)EILSEQの店舗errno、および詳細不明の状態で*psを残し.
Original:
On failure (if wc is not a valid wide character), returns static_cast<std::size_t>(-1), stores EILSEQ in errno, and leaves *ps in unspecified state.
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 <string>
#include <cwchar>
 
void print_wide(const std::wstring& wstr)
{
    std::mbstate_t state = std::mbstate_t();
    for(wchar_t wc : wstr) {
        std::string mb(MB_CUR_MAX, '\0');
        int ret = std::wcrtomb(&mb[0], wc, &state);
        std::cout << "multibyte char " << mb << " is " << ret << " bytes\n";
    }
}
 
int main()
{
    std::setlocale(LC_ALL, "en_US.utf8");
    // UTF-8 narrow multibyte encoding
    std::wstring wstr = L"z\u00df\u6c34\U0001d10b"; // or L"zß水𝄋"
    print_wide(wstr);
}

Output:

multibyte char z is 1 bytes
multibyte char ß is 2 bytes
multibyte char 水 is 3 bytes
multibyte char 𝄋 is 4 bytes

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

そのマルチバイト表現にワイド文字に変換します
Original:
converts a wide character to its multibyte representation
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 the next multibyte character to wide character, 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]
[仮想]
そのようなファイルに書き込むときのように、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 wcrtomb