std::codecvt::max_length, std::codecvt::do_max_length
来自cppreference.com
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
在头文件 <locale> 中定义
|
||
public: int max_length() const |
(1) | |
protected: int do_max_length() const |
(2) | |
公共成员函数,调用最派生类的成员函数
do_max_length
.原文:
public member function, calls the member function
do_max_length
of the most derived class.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
原文:
The non-converting specialization std::codecvt<char, char, std::mbstate_t> returns 1
[编辑] 注释
If the encoding is state-dependent (encoding() == -1), then more than max_length()
external characters may be consumed to produce one internal character
[编辑] 例外
[编辑] 示例
#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_MAX |
在当前的Clocale
(宏变量)多字节字符的最大字节数 原文: maximum number of bytes in a multibyte character in the current C locale (宏变量) |
[虚]</div></div>
|
返回的externT需要产生一个Internt的字符的字符数,如果不变 原文: returns the number of externT characters necessary to produce one internT character, if constant (虚拟保护成员函数) |