名前空間
変種
操作

std::wstring_convert::wstring_convert

提供: cppreference.com

 
 
ローカライゼーションライブラリ
ロケールおよびファセット
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.
 
std::wstring_convert
メンバ関数
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
wstring_convert::wstring_convert
wstring_convert::~wstring_convert
wstring_convert::from_bytes
wstring_convert::to_bytes
wstring_convert::converted
wstring_convert::state
 
wstring_convert( Codecvt* pcvt = new Codecvt );
(1)
wstring_convert( Codecvt* pcvt, state_type state);
(2)
wstring_convert( const byte_string& byte_err, const wide_string& wide_err = wide_string() );
(3)
1)
シフト状態とエラー文字列のデフォルトに構成された値を使用して、指定された変換ファセットとwstring_convertオブジェクトを構築します
Original:
Constructs the wstring_convert object with a specified conversion facet, using default-constructed values for the shift state and the error strings
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
エラー文字列デフォルト値を使用して構築され、指定された変換ファセットと指定されたシフト状態とwstring_convertオブジェクトを構築します
Original:
Constructs the wstring_convert object with a specified conversion facet and specified shift state, using default-constructed values for the error strings
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
3)
変換ファセットおよびdefault-構築wstring_convertとしてのシフト状態としてnew Codecvtを使用して、指定されたエラー文字列をstate_typeオブジェクトを構築し.
Original:
Constructs the wstring_convert object with specified error strings, using new Codecvt as the conversion facet and the default-constructed state_type as shift state.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] パラメータ

pcvt -
タイプCodecvtの変換ファセットへのポインタ
Original:
pointer to the conversion facet of type Codecvt
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
state -
変換のシフト状態の初期値
Original:
initial value of the conversion shift state
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
byte_err -
エラーの際に表示する文字列狭い
Original:
narrow string to display on errors
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
wide_err -
エラーの際に表示するワイド文字列
Original:
wide string to display on errors
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集]

#include <locale>
#include <utility>
#include <codecvt>
 
// utility wrapper to adapt locale-bound facets for wstring/wbuffer convert
template<class Facet>
struct deletable_facet : Facet
{
    template<class ...Args>
    deletable_facet(Args&& ...args) : Facet(std::forward<Args>(args)...) {}
    ~deletable_facet() {}
};
 
int main()
{
    // UTF-16le / UCS4 conversion
    std::wstring_convert<std::codecvt_utf16<char32_t, 0x10ffff, std::little_endian>> u16to32;
 
    // UTF-8 / wide string conversion with custom messages
    std::wstring_convert<std::codecvt_utf8<wchar_t>> u8towide("Error!", L"Error!");
 
    // GB18030 / wide string conversion facet
    typedef deletable_facet<std::codecvt_byname<wchar_t, char, std::mbstate_t>> F;
    std::wstring_convert<F> gbtowide(new F("zh_CN.gb18030"));
}