在线文档教程
C++
本土化 | Localizations

do_max_length

STD::编解码器::MAX[医]长度,做[医]马克斯[医]长度

Defined in header
public: int max_length() const;(1)
protected: virtual int do_max_length() const;(2)

1%29公共成员函数,调用成员函数do_max_length最派生的类。

2%29返回最大值do_length(state, from, from_end, 1)可以返回任何有效范围。[from, from_end)任何有效的state...

返回值

最大数目ExternT转换时可以使用的字符。in()生产一个InternT性格。

非转换专业化std::codecvt<char, char,std::mbstate_t>回报1...

注记

如果编码是状态相关的%28encoding() == -1%29,然后超过max_length()外部字符可以被消耗以产生一个内部字符。

例外

(none)(until C++11)
noexcept specification: noexcept(since 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"; }

二次

产出:

二次

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_MAXmaximum number of bytes in a multibyte character in the current C locale(macro variable)
do_encoding virtualreturns the number of externT characters necessary to produce one internT character, if constant (virtual protected member function)

© cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

http://en.cppreference.com/w/cpp/locale/codecvt/max[医]长度