名前空間
変種
操作

std::wstring_convert::from_bytes

提供: 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
 
Defined in header <locale>
wide_string from_bytes( char byte );
(1)
wide_string from_bytes( const char* ptr );
(2)
wide_string from_bytes( const byte_string& str );
(3)
wide_string from_bytes( const char* first, const char* last);
(4)
建設で供給codecvtファセットを使用して、ワイドコンバージョンにマルチバイト実行.
Original:
Performs multibyte to wide conversion, using the codecvt facet supplied at construction.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
1)
それはwide_stringに長byteの文字列であるかのように1変換します
Original:
Converts byte as if it was a string of length 1 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.
2)
wide_stringにptrが指す文字でNULLで終わるマルチバイト文字列の先頭を変換します
Original:
Converts the null-terminated multibyte character sequence beginning at the character pointed to by ptr 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.
3)
wide_stringに狭い列strを変換.
Original:
Converts the narrow string str 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.
4)
wide_stringに狭いマルチバイト文字シーケンス[first, last)に変換します
Original:
Converts the narrow multibyte character sequence [first, last) 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.
非初期起動状態がこのwstring_convertコンストラクタに提供されていない限り、すべての例では、変換は、初期シフト状態で始まる。変換された文字数と変換状態の最終的な値は記憶されているとstate()converted()でアクセスすることができます
Original:
In all cases, the conversion begins in initial shift state, unless non-initial starting state was provided to this wstring_convert constructor. The number of characters converted and the final value of the conversion state are remembered and can be accessed with state() and converted()
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

目次

[編集] 値を返します

ワイドコンバージョンにマルチバイトの結果を含むwide_stringオブジェクト。変換が失敗し、このwstring_convertのコンストラクタで指定したユーザ供給のワイドエラー文字列がありました場合は、そのワイドエラー文字列を返します。.
Original:
A wide_string object containing the results of multibyte to wide conversion. If the conversion failed and there was a user-supplied wide-error string provided to the constructor of this wstring_convert, returns that wide-error string.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 例外

このwstring_convertオブジェクトは、ユーザ供給ワイドエラー文字列なしで構築された場合、変換に失敗したstd::range_errorをスロー.
Original:
If this wstring_convert object was constructed without a user-supplied wide-error string, throws std::range_error on conversion failure.
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>
#include <codecvt>
int main()
{
    std::string utf8 =  u8"z\u00df\u6c34\U0001d10b"; // or u8"zß水𝄋"
                        // or "\x7a\xc3\x9f\xe6\xb0\xb4\xf0\x9d\x84\x8b";
 
    // the UTF-8 / UTF-16 standard conversion facet
    std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> utf16conv;
    std::u16string utf16 = utf16conv.from_bytes(utf8.data());
    std::cout << "UTF16 conversion produced " << utf16.size() << " code points:\n";
    for(char16_t c : utf16)
        std::cout << std::hex << std::showbase << c << '\n';
 
    // the UTF-8 / UTF-32 standard conversion facet
    std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> utf32conv;
    std::u32string utf32 = utf32conv.from_bytes(utf8);
    std::cout << "UTF32 conversion produced " << std::dec << utf32.size() << " code points:\n";
    for(char32_t c : utf32)
        std::cout << std::hex << std::showbase << c << '\n';
}

Output:

UTF16 conversion produced 5 code points:
0x7a
0xdf
0x6c34
0xd834
0xdd0b
UTF32 conversion produced 4 code points:
0x7a
0xdf
0x6c34
0x1d10b

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

バイト文字列にワイド文字列に変換します
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.

(パブリックメンバ関数) [edit]
ワイド文字列へのナローマルチバイト文字列、与えられた状態に変換します
Original:
converts a narrow multibyte character string to wide 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メンバ関数of std::codecvt) [edit]