It returns the width of an internal character in terms of external characters, if this is a fixed value. Otherwise, if this is a variable value, the function returns 0.
DeclarationFollowing is the declaration for std::ctype::encoding.
C++98int encoding() const throw();C++11
int encoding() const throw();Parameters
none
Return ValueIt returns the width of an internal character in terms of external characters, if this is a fixed value.
ExceptionsNo-throw guarantee − never throws exceptions.
Data racesThe facet object is accessed.
ExampleIn below example explains about std::ctype::encoding.
#include <iostream> #include <locale> int main () { std::locale loc; const std::codecvt<wchar_t,char,mbstate_t>& myfacet = std::use_facet<std::codecvt<wchar_t,char,mbstate_t> >(loc); std::cout << "Characteristics of codecvt<wchar_t,char,mbstate_t>:\n"; std::cout << "Encoding: " << myfacet.encoding() << '\n'; std::cout << "Always noconv: " << myfacet.always_noconv() << '\n'; std::cout << "Max length: " << myfacet.max_length() << '\n'; return 0; }
Let us compile and run the above program, this will produce the following result −
Characteristics of codecvt<wchar_t,char,mbstate_t>: Encoding: 1 Always noconv: 0 Max length: 1
locale.htm
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4