名前空間
変種
操作

std::codecvt::max_length, std::codecvt::do_max_length

提供: 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:
int max_length() const
(1)
protected:
int do_max_length() const
(2)
1)
パブリックメンバ関数は、最派生クラスのメンバ関数を呼び出しdo_max_length.
Original:
public member function, calls the member function do_max_length 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) returns the maximum value that do_length(state, from, from_end, 1) can return for any valid range [from, from_end) and any valid state.

目次

[編集] 値を返します

The maximum number of externT characters that could be consumed if converted by do_in() to produce one internT character.

非変換分業std::codecvt<char, char, std::mbstate_t>戻り1
Original:
The non-converting specialization std::codecvt<char, char, std::mbstate_t> returns 1
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] ノート

If the encoding is state-dependent (encoding() == -1), then more than max_length() external characters may be consumed to produce one internal character

[編集] 例外

noexcept specification:  
noexcept
  (C++11およびそれ以降)

[編集]

#include <locale>
#include <iostream>
#include <codecvt>
int main()
{
    std::cout << "In codecvt_utf8, the longest multibyte character is "
              << std::codecvt_utf8<wchar_t>().max_length() << " bytes long\n";
 
    std::cout << "In header-consuming codecvt_utf8, the longest multibyte character is "
              << std::codecvt_utf8<wchar_t,
                                   0x10ffff,
                                   std::consume_header>().max_length() << " bytes long\n";
 
    std::cout << "In this system's en_US.utf8, the longest multibyte character is "
              << std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t>>(
                    std::locale("en_US.utf8")
              ).max_length() << " bytes long\n";
 
    std::cout << "In this system's zh_CN.gb18030, the longest multibyte character is "
              << std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t>>(
                    std::locale("zh_CN.gb18030")
              ).max_length() << " bytes long\n";
}

Output:

In codecvt_utf8, the longest multibyte character is 4 bytes long
In header-consuming codecvt_utf8, the longest multibyte character is 7 bytes long
In this system's en_US.utf8, the longest multibyte character is 6 bytes long
In this system's zh_CN.gb18030, the longest multibyte character is 4 bytes long

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

MB_CUR_MAX
現在のClocale
(マクロ変数)のマルチバイト文字の最大バイト数
Original:
maximum number of bytes in a multibyte 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.
[edit]
[仮想]
一定の場合には、1 internT文字を生成するのに必要なexternT文字の数を返します
Original:
returns the number of externT characters necessary to produce one internT character, if constant
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

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