名前空間
変種
操作

std::codecvt::out, std::codecvt::do_out

提供: cppreference.com
< cpp‎ | locale‎ | codecvt

 
 
ローカライゼーションライブラリ
ロケールおよびファセット
Original:
Locales and facets
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
locale
文字分類
Original:
Character classification
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
変換
Original:
Conversions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ファセットカテゴリの基底クラスです
Original:
Facet category base classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ファセットカテゴリ
Original:
Facet categories
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ロケール固有のファセット
Original:
Locale-specific facets
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
コー​​ド変換ファセット
Original:
Code conversion facets
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
codecvt_utf8(C++11)
codecvt_utf16(C++11)
Cロケール
Original:
C locale
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 
 
Defined in header <locale>
public:

result out( stateT& state,
            const internT* from,
            const internT* from_end,
            const internT*& from_next,
            externT* to,
            externT* to_end,

            externT*& to_next ) const;
(1)
protected:

result do_out( stateT& state,
               const internT* from,
               const internT* from_end,
               const internT*& from_next,
               externT* to,
               externT* to_end,

               externT*& to_next ) const;
(2)
1)
パブリックメンバ関数は、最派生クラスのメンバ関数を呼び出しdo_out.
Original:
public member function, calls the member function do_out of the most derived class.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
このcodecvtファセットが変換を定義する場合、[from, from_end)から始まるその後の場所に結果を配置し、外部文字にソース範囲toから内部の文字を変換します。 from_end - from内部文字以上のものを変換しないとto_end - to外部文字以上のものを書き込みません​​。葉from_nextto_next正常に変換最後の要素を超えたものを指している.
Original:
If this codecvt facet defines a conversion, translates the internal characters from the source range [from, from_end) to external characters, placing the results in the subsequent locations starting at to. Converts no more than from_end - from internal characters and writes no more than to_end - to external characters. Leaves from_next and to_next pointing one beyond the last element successfully converted.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
このcodecvtファセットは、変換が定義されていない場合、文字は変換されません。 to_nexttoに等しくなるように設定されている、state変更されず、std::codecvt_base::noconvが返されます。.
Original:
If this codecvt facet does not define a conversion, no characters are converted. to_next is set to be equal to to, state is unchanged, and std::codecvt_base::noconv is returned.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

目次

[編集] 値を返します

次のように、成功のステータスを示すタイプstd::codecvt_base::resultの値:
Original:
A value of type std::codecvt_base::result, indicating the success status as follows:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ok
変換が完了しました
Original:
conversion completed
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
partial
しない出力バッファに十分なスペースや、ソース·バッファの予期しない終了
Original:
not enough space in the output buffer or unexpected end of source buffer
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
error
変換できなかった文字を検出しました
Original:
encountered a character that could not be converted
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
noconv
このファセットは、書き出される出力非変換ではありません
Original:
this facet is non-converting, no output written
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
非変換の専門はstd::codecvt<char, char, std::mbstate_t>常にstd::codecvt_base::noconvを返します
Original:
The non-converting specialization std::codecvt<char, char, std::mbstate_t> always returns std::codecvt_base::noconv
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] ノート

どちら初期シフト状態を表すか、または順番に前の文字を変換して得られることfrom <= from_end && to <= to_endそのstateが必要.
Original:
Requires that from <= from_end && to <= to_end and that state either representing the initial shift state or obtained by converting the preceding characters in the sequence.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
codecvtNがサポートされていますが、Mの変換(例えば、UTF-16、UTF-8には、2つの内部の文字が出力にどのような外字を決定する必要があるかもしれないところ)、std::basic_filebufは1つだけを定義codecvtファセットを使用することができます:Nの変換は、それはそれであるファイルへの書き込み時に1内部文字を処理できなければなりません.
Original:
While codecvt supports N:M conversions (e.g. UTF-16 to UTF-8, where two internal characters may be necessary to decide what external characters to output), std::basic_filebuf can only use codecvt facets that define a 1:N conversion, that is it must be able to process one internal character at a time when writing to a file.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Nを実行するとき:Mの変換の場合、この関数はすべてのソース文字(std::codecvt_base::partial)消費した後を返すかもしれません。これは、別の内部文字(例えば、ソース·バッファ内の最後の文字が上位サロゲートである場合は、UTF-8からUTF-16に変換するときに)変換を完了するために必要であることを意味します.
Original:
When performing N:M conversions, this function may return std::codecvt_base::partial after consuming all source characters (). This means that another internal character is needed to complete the conversion (e.g. when converting UTF-16 to UTF-8, if the last character in the source buffer is a high surrogate).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
stateへの影響は意図的に特定されていません。標準ファセットでは、std::wcsrtombsを呼び出すときのようなシフト状態を維持するために使用されるため、最後に正常に変換された文字列の後のシフト状態を反映するように更新されますが、ユーザが定義したファセットは、例えば、他の任意の状態を維持するためにそれを使用して自由である遭遇した特殊文字の数をカウント.
Original:
The effect on state is deliberately unspecified. In standard facets, it is used to maintain shift state like when calling std::wcsrtombs, and is therefore updated to reflect the shift state after the last successfully converted character, but a user-defined facet is free to use it to maintain any other state, e.g. count the number of special characters encountered.
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 <string>
#include <locale>
int main()
{
    std::locale::global(std::locale("en_US.utf8"));
    auto& f = std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t>>(std::locale());
    std::wstring internal = L"z\u00df\u6c34\U0001d10b"; // L"zß水𝄋"
 
    // note that the following can be done with wstring_convert
    std::mbstate_t mb = std::mbstate_t(); // initial shift state
    std::string external(internal.size() * f.max_length(), '\0'); 
    const wchar_t* from_next;
    char* to_next;
    f.out(mb, &internal[0], &internal[internal.size()], from_next,
              &external[0], &external[external.size()], to_next);
    // error checking skipped for brevity
    external.resize(to_next - &external[0]);
 
    std::cout << "The string in narrow multibyte encoding: " << external << '\n';
}

Output:

The string in narrow multibyte encoding: zß水𝄋

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

[仮想]
put領域から関連付けられたファイルに文字を書き込みます
Original:
writes characters to the associated file from the put area
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::basic_filebuf) [edit]
バイト文字列にワイド文字列に変換します
Original:
converts a wide string into a byte string
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数of std::wstring_convert) [edit]
ナローマルチバイト文字列、所定の状態にワイド文字列に変換します
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]
[仮想]
そのようなファイルからの読み込みの場合のように、externTからinternTに文字列を変換します
Original:
converts a string from externT to internT, such as when reading from file
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(仮想protectedメンバ関数) [edit]