std::codecvt::out, std::codecvt::do_out
Da cppreference.com.
|
|
Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate.
La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
<metanoindex/>
<tbody> </tbody>| Elemento definito nell'header <locale>
|
||
public: result out( stateT& state, const internT* from, const internT* from_end, const internT*& from_next, externT* to, externT* to_end, externT*& to_next ) const; |
(1) | |
protected: result do_out( stateT& state, const internT* from, const internT* from_end, const internT*& from_next, externT* to, externT* to_end, externT*& to_next ) const; |
(2) | |
1)
funzione membro pubblica, chiama la
do_out funzione membro della classe più derivata.Original:
public member function, calls the member function
do_out 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.
You can help to correct and verify the translation. Click here for instructions.
2)
Se questo aspetto
codecvt definisce una conversione, traduce i caratteri interni della [from, from_end) intervallo di origine a caratteri esterni, mettendo i risultati nelle posizioni successive a partire da to. Converte più di caratteri from_end - from interni e scrive più di caratteri to_end - to esterni. 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 internal characters from the source range [from, from_end) to external characters, placing the results in the subsequent locations starting at to. Converts no more than from_end - from internal characters and writes no more than to_end - to external 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.
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.
You can help to correct and verify the translation. Click here for instructions.
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.
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::noconvOriginal:
The non-converting specialization
std::codecvt<char, char, std::mbstate_t> always returns std::codecvt_base::noconvThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
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.
You can help to correct and verify the translation. Click here for instructions.
Mentre
codecvt supporta N: M conversioni (ad esempio UTF-16 a UTF-8, in cui due personaggi interni potrebbe essere necessario decidere ciò che i caratteri esterni di uscita), std::basic_filebuf possibile utilizzare solo gli aspetti che definiscono un codecvt 1: conversione di N, che è deve essere in grado di elaborare un carattere interno alla volta quando si scrive in un file.Original:
While
codecvt supports N:M conversions (e.g. UTF-16 to UTF-8, where two internal characters may be necessary to decide what external characters to output), std::basic_filebuf can only use codecvt facets that define a 1:N conversion, that is it must be able to process one internal character at a time when writing to a file.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Durante l'esecuzione di N: M conversioni, questa funzione può restituire std::codecvt_base::partial dopo aver consumato tutti i caratteri di origine (
). Ciò significa che un altro carattere interno è necessario per completare la conversione (ad esempio quando la conversione UTF-16 a UTF-8, se l'ultimo carattere del buffer di origine è un surrogato alto).Original:
When performing N:M conversions, this function may return std::codecvt_base::partial after consuming all source characters (
). This means that another internal character is needed to complete the conversion (e.g. when converting UTF-16 to UTF-8, if the last character in the source buffer is a high surrogate).The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
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::wcsrtombs, ed è quindi aggiornato per riflettere lo stato del cambio dopo l'ultimo carattere convertito con successo, 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::wcsrtombs, and is therefore updated to reflect the shift state after the last successfully converted 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.
You can help to correct and verify the translation. Click here for instructions.
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::wstring internal = L"z\u00df\u6c34\U0001d10b"; // L"zß水𝄋"
// note that the following can be done with wstring_convert
std::mbstate_t mb = std::mbstate_t(); // initial shift state
std::string external(internal.size() * f.max_length(), '\0');
const wchar_t* from_next;
char* to_next;
f.out(mb, &internal[0], &internal[internal.size()], from_next,
&external[0], &external[external.size()], to_next);
// error checking skipped for brevity
external.resize(to_next - &external[0]);
std::cout << "The string in narrow multibyte encoding: " << external << '\n';
}
Output:
The string in narrow multibyte encoding: zß水𝄋
Vedi anche
[virtuale] |
scrive i caratteri nel file associato dalla zona put Original: writes characters to the associated file from the put area 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)
|
converte una stringa larga in una stringa di byte Original: converts a wide string into a byte string The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico) | |
converte una stringa larga a stretta stringa a caratteri multibyte, determinato stato Original: converts a wide string to narrow multibyte character 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) | |
[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) |