Namespace
Varianti

std::codecvt::length, std::codecvt::do_length

Da cppreference.com.
< cpp‎ | locale‎ | codecvt

 
 
Localizzazioni libreria
Impostazioni internazionali e sfaccettature
Original:
Locales and facets
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
locale
Carattere classificazione
Original:
Character classification
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Conversioni
Original:
Conversions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Facet categoria classi di base
Original:
Facet category base classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Facet categorie
Original:
Facet categories
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Locale specifici aspetti
Original:
Locale-specific facets
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Codice di conversione sfaccettature
Original:
Code conversion facets
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
codecvt_utf8(C++11)
codecvt_utf16(C++11)
C locale
Original:
C locale
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 
 
Elemento definito nell'header <locale>
public:

int length( stateT& state,
            const externT* from,
            const externT* from_end,

            std::size_t max ) const
(1)
protected:

int do_length( stateT& state,
               const externT* from,
               const externT* from_end,

               std::size_t max ) const
(2)
1)
funzione membro pubblica, chiama la do_length funzione membro della classe più derivata.
Original:
public member function, calls the member function do_length of the most derived class.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
i tentativi di convertire i caratteri externT dalla matrice di caratteri definito da [from, from_end), dato iniziale state stato di conversione, di al massimo max internT caratteri, e restituisce il numero di caratteri externT che tale trasformazione si consumano. Modifica state come se eseguendo do_in(state, from, from_end, from, to, to+max, to) per alcuni buffer di uscita immaginaria [to, to+max).
Original:
attempts to convert the externT characters from the character array defined by [from, from_end), given initial conversion state state, to at most max internT characters, and returns the number of externT characters that such conversion would consume. Modifies state as if by executing do_in(state, from, from_end, from, to, to+max, to) for some imaginary [to, to+max) output buffer.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Valore di ritorno

Il numero di caratteri externT che sarebbero consumati in caso di conversione da do_in() fino a visualizzare tutti i caratteri from_end-from sono stati consumati o max internT personaggi erano produttore, o si è verificato un errore di conversione.
Original:
The number of externT characters that would be consumed if converted by do_in() until either all from_end-from characters were consumed or max internT characters were producer, or a conversion error occurred.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
La mancata conversione di specializzazione std::codecvt<char, char, std::mbstate_t> rendimenti std::min(max, from_end-from)
Original:
The non-converting specialization std::codecvt<char, char, std::mbstate_t> returns std::min(max, from_end-from)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Esempio

#include <locale>
#include <string>
#include <iostream>
int main()
{
    //  narrow multibyte encoding
    std::string s = "z\u00df\u6c34\U0001d10b"; // or u8"zß水𝄋"
                      // or "\x7a\xc3\x9f\xe6\xb0\xb4\xf0\x9d\x84\x8b";
    std::mbstate_t mb = std::mbstate_t();
    std::cout << "Only the first " <<
              std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t>>(
                    std::locale("en_US.utf8")
              ).length(mb, &s[0], &s[s.size()], 2)
              << " bytes out of " << s.size() << " would be consumed "
                 " to produce the first 2 characters\n";
}

Output:

Only the first 3 bytes out of 10 would be consumed to produce the first 2 characters

Vedi anche

[virtuale]
converte una stringa da externT a internt, come ad esempio durante la lettura dal file
Original:
converts a string from externT to internT, such as when reading from file
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(virtuale protetto funzione membro) [modifica]