std::codecvt<InternT,ExternT,StateT>:: max_length, do_max_length
|
Défini dans l'en-tête
<locale>
|
||
| (1) | ||
|
public
:
int max_length ( ) const throw ( ) ; |
(jusqu'à C++11) | |
|
public
:
int max_length ( ) const noexcept ; |
(depuis C++11) | |
| (2) | ||
|
protected
:
virtual int do_max_length ( ) const throw ( ) ; |
(jusqu'à C++11) | |
|
protected
:
virtual int do_max_length ( ) const noexcept ; |
(depuis C++11) | |
do_max_length
de la classe la plus dérivée.
[
from
,
from_end
)
et tout
state
valide.
Table des matières |
Valeur de retour
Le nombre maximum de caractères
ExternT
qui pourraient être consommés si convertis par
in()
pour produire un caractère
InternT
.
La spécialisation non-convertissante std:: codecvt < char , char , std:: mbstate_t > retourne 1 .
Notes
Si l'encodage dépend de l'état (
encoding
(
)
==
-
1
), alors plus de
max_length()
caractères externes peuvent être consommés pour produire un caractère interne.
Exemple
#include <codecvt> #include <iostream> #include <locale> 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"; }
Sortie :
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
Voir aussi
|
MB_CUR_MAX
|
nombre maximum d'octets dans un caractère multioctet dans la locale C actuelle
(macro variable) |
|
[virtual]
|
retourne le nombre de
ExternT
caractères nécessaires pour produire un
InternT
caractère, si constant
(fonction membre protégée virtuelle) |