std::codecvt<InternT,ExternT,State>::encoding,do_encoding (3) - Linux Manuals
std::codecvt<InternT,ExternT,State>::encoding,do_encoding: std::codecvt<InternT,ExternT,State>::encoding,do_encoding
Command to display std::codecvt<InternT,ExternT,State>::encoding,do_encoding
manual in Linux: $ man 3 std::codecvt<InternT,ExternT,State>::encoding,do_encoding
NAME
std::codecvt<InternT,ExternT,State>::encoding,do_encoding - std::codecvt<InternT,ExternT,State>::encoding,do_encoding
Synopsis
Defined in header <locale>
public: (1)
int encoding() const;
protected: (2)
virtual int do_encoding() const;
1) 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.
Return value
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.
The non-converting specialization std::codecvt<char, char, std::mbstate_t> returns 1
Exceptions
(none) (until C++11)
noexcept specification: (since C++11)
noexcept
Example
// Run this code
#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';
}
Output:
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
See also
maximum number of bytes in a multibyte character in the current C locale
MB_CUR_MAX (macro variable)
do_max_length returns the maximum number of externT characters that could be converted into a single internT character
(virtual protected member function)
[virtual]
Pages related to std::codecvt<InternT,ExternT,State>::encoding,do_encoding
- std::codecvt<InternT,ExternT,State>::always_noconv,do_always_noconv (3) - std::codecvt<InternT,ExternT,State>::always_noconv,do_always_noconv
- std::codecvt<InternT,ExternT,State>::codecvt (3) - std::codecvt<InternT,ExternT,State>::codecvt
- std::codecvt<InternT,ExternT,State>::in,std::codecvt<InternT,ExternT,State>::do_in (3) - std::codecvt<InternT,ExternT,State>::in,std::codecvt<InternT,ExternT,State>::do_in
- std::codecvt<InternT,ExternT,State>::length,do_length (3) - std::codecvt<InternT,ExternT,State>::length,do_length
- std::codecvt<InternT,ExternT,State>::max_length,do_max_length (3) - std::codecvt<InternT,ExternT,State>::max_length,do_max_length
- std::codecvt<InternT,ExternT,State>::out,do_out (3) - std::codecvt<InternT,ExternT,State>::out,do_out
- std::codecvt<InternT,ExternT,State>::unshift,do_unshift (3) - std::codecvt<InternT,ExternT,State>::unshift,do_unshift
- std::codecvt<InternT,ExternT,State>::~codecvt (3) - std::codecvt<InternT,ExternT,State>::~codecvt
- std::codecvt (3) - std::codecvt
- std::codecvt_base (3) - std::codecvt_base
- std::codecvt_byname (3) - std::codecvt_byname
- std::codecvt_mode (3) - std::codecvt_mode
- std::codecvt_utf8 (3) - std::codecvt_utf8
- std::codecvt_utf8_utf16 (3) - std::codecvt_utf8_utf16
- std::codecvt_utf16 (3) - std::codecvt_utf16
- std::collate (3) - std::collate