GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::codecvt::encoding,do_encoding(3) C++ Standard Libary std::codecvt::encoding,do_encoding(3)

std::codecvt::encoding,do_encoding - std::codecvt::encoding,do_encoding


Defined in header <locale>
public: (until C++11)
int encoding() const throw();
public: (since C++11)
int encoding() const noexcept; (1)
protected: (until C++11)
virtual int do_encoding() const throw(); (2)
protected: (since C++11)
virtual int do_encoding() const noexcept;


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.


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

// 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';
}


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


maximum number of bytes in a multibyte character in the current C
MB_CUR_MAX locale
(macro variable)
do_max_length returns the maximum number of externT characters that could be
[virtual] converted into a single internT character
(virtual protected member function)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.