std::codecvt::encoding, std::codecvt::do_encoding
来自cppreference.com
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
在头文件 <locale> 中定义
|
||
public: int encoding() const |
(1) | |
protected: int do_encoding() const |
(2) | |
公共成员函数,调用最派生类的成员函数
do_encoding
.原文:
public member function, calls the member function
do_encoding
of the most derived class.2) if the encoding represented by this codecvt facet maps each internal character to the same, constant number of external characters, returns that number. If the encoding is variable-length (e.g. UTF-8 or UTF-16), returns 0. If the encoding is state-dependent, returns -1.
目录 |
[编辑] 返回值
The exact number of externT
characters that correspond to one internT
character, if constant. 0 if the number varies, -1 if the encoding is state-dependent.
非转换专业化std::codecvt<char, char, std::mbstate_t>回报1
原文:
The non-converting specialization std::codecvt<char, char, std::mbstate_t> returns 1
[编辑] 例外
[编辑] 示例
#include <locale> #include <iostream> int main() { std::cout << "en_US.utf8 is a variable-length encoding, encoding() returns " << std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t>>( std::locale("en_US.utf8") ).encoding() << '\n'; std::cout << "zh_CN.gb18030 is also variable-length, encoding() == " << std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t>>( std::locale("zh_CN.gb18030") ).encoding() << '\n'; std::cout << "ru_RU.koi8r is a single-byte encoding encoding() == " << std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t>>( std::locale("ru_RU.koi8r") ).encoding() << '\n'; }
输出:
en_US.utf8 is a variable-length encoding, encoding() returns 0 zh_CN.gb18030 is also variable-length, encoding() == 0 ru_RU.koi8r is a single-byte encoding encoding() == 1
[编辑] 另请参阅
MB_CUR_MAX |
在当前的Clocale
(宏变量)多字节字符的最大字节数 原文: maximum number of bytes in a multibyte character in the current C locale (宏变量) |
[虚]</div></div>
|
返回的最大数目,可以被转换成一个单一的Internt的字符externT字符 原文: returns the maximum number of externT characters that could be converted into a single internT character (虚拟保护成员函数) |