Namespace
Varianti

std::codecvt::in, std::codecvt::do_in

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.
 
 
Defined in header <locale>
public:

result in( stateT& state,
           const externT* from,
           const externT* from_end,
           const externT*& from_next,
           internT* to,
           internT* to_end,

           internT*& to_next ) const;
(1)
protected:

result do_in( stateT& state,
              const externT* from,
              const externT* from_end,
              const externT*& from_next,
              internT* to,
              internT* to_end,

              internT*& to_next ) const;
(2)
1)
funzione membro pubblica, chiama la do_in funzione membro della classe più derivata.
Original:
public member function, calls the member function do_in 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)
Se questo aspetto codecvt definisce una conversione, traduce i caratteri esterni dalla [from, from_end) intervallo di origine ai caratteri interni, ponendo i risultati nelle posizioni successive a partire da to. Converte più di caratteri from_end - from esterni e scrive più di caratteri to_end - to interni. Foglie from_next e to_next indicando uno oltre l'ultimo elemento convertito con successo.
Original:
If this codecvt facet defines a conversion, translates the external characters from the source range [from, from_end) to internal characters, placing the results in the subsequent locations starting at to. Converts no more than from_end - from external characters and writes no more than to_end - to internal characters. Leaves from_next and to_next pointing one beyond the last element successfully converted.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Se questo aspetto codecvt non definisce una conversione, non i caratteri vengono convertiti. to_next è impostato per essere uguale a to, state è immutato, e std::codecvt_base::noconv viene restituito.
Original:
If this codecvt facet does not define a conversion, no characters are converted. to_next is set to be equal to to, state is unchanged, and std::codecvt_base::noconv is returned.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Indice

[modifica] Valore di ritorno

Un valore di std::codecvt_base::result tipo, che indica lo stato di successo come segue:
Original:
A value of type std::codecvt_base::result, indicating the success status as follows:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ok
conversione completata
Original:
conversion completed
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
partial
abbastanza spazio nel buffer di uscita o inaspettata fine del buffer di origine
Original:
not enough space in the output buffer or unexpected end of source buffer
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
error
incontrato un personaggio che non può essere convertito
Original:
encountered a character that could not be converted
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
noconv
questo aspetto non è di conversione, nessuna uscita scritta
Original:
this facet is non-converting, no output written
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
La specializzazione non convertire std::codecvt<char, char, std::mbstate_t> restituisce sempre std::codecvt_base::noconv
Original:
The non-converting specialization std::codecvt<char, char, std::mbstate_t> always returns std::codecvt_base::noconv
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[modifica] Note

Richiede che from <= from_end && to <= to_end e che state o rappresentare lo stato iniziale del cambio o ottenuti convertendo i caratteri precedenti nella sequenza.
Original:
Requires that from <= from_end && to <= to_end and that state either representing the initial shift state or obtained by converting the preceding characters in the sequence.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
L'effetto sulla state è volutamente non specificato. In sfaccettature standard, viene utilizzato per mantenere lo stato di spostamento, come quando si chiama std::mbsrtowcs, ed è quindi aggiornato per riflettere lo stato di conversione dopo l'ultimo carattere trasformato esterno, ma un aspetto definito dall'utente è libero di usarlo per mantenere qualsiasi altro stato, ad esempio, contare il numero di caratteri speciali incontrate.
Original:
The effect on state is deliberately unspecified. In standard facets, it is used to maintain shift state like when calling std::mbsrtowcs, and is therefore updated to reflect the conversion state after the last processed external character, but a user-defined facet is free to use it to maintain any other state, e.g. count the number of special characters encountered.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[modifica] Esempio

#include <iostream>
#include <string>
#include <locale>
int main()
{
    std::locale::global(std::locale("en_US.utf8"));
    auto& f = std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t>>(std::locale());
    std::string external = u8"z\u00df\u6c34\U0001d10b"; // or u8"zß水𝄋"
                          // or "\x7a\xc3\x9f\xe6\xb0\xb4\xf0\x9d\x84\x8b";
 
    // note that the following can be done with wstring_convert
    std::mbstate_t mb = std::mbstate_t(); // initial shift state
    std::wstring internal(external.size(), '\0'); 
    const char* from_next;
    wchar_t* to_next;
    f.in(mb, &external[0], &external[external.size()], from_next,
             &internal[0], &internal[internal.size()], to_next);
    // error checking skipped for brevity
    internal.resize(to_next - &internal[0]);
 
    std::wcout << L"The string in wide encoding: " << internal << '\n';
}

Output:

The string in wide encoding: zß水𝄋

[modifica] Vedi anche

[virtuale]
legge dal file associato
Original:
reads from the associated 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 of std::basic_filebuf membro) [edit]
converte una stringa di byte in una stringa di larghezza
Original:
converts a byte string into a wide string
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(membro pubblico of std::wstring_convert funzione) [edit]
converte una stringa di caratteri multibyte stretta alla stringa di larghezza, determinato stato
Original:
converts a narrow multibyte character string to wide string, given state
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(funzione) [edit]
[virtuale]
converte una stringa da internt a externT, come ad esempio durante la scrittura su file
Original:
converts a string from internT to externT, such as when writing to 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) [edit]