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::max_length,do_max_length(3) C++ Standard Libary std::codecvt::max_length,do_max_length(3)

std::codecvt::max_length,do_max_length - std::codecvt::max_length,do_max_length


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


1) 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 in()
to produce one InternT character.


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

// Run this code


#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 maximum number of bytes in a multibyte character in the current C locale
(macro variable)
do_encoding returns the number of externT characters necessary to produce one
[virtual] internT character, if constant
(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.