Espacios de nombres
Variantes
Acciones

std::codecvt::out, std::codecvt::do_out

De cppreference.com
< cpp‎ | locale‎ | codecvt
 
 
 
 
Definido en el archivo de encabezado <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)
función miembro pública, llama a la función do_out miembro de la clase más derivada .
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.
2)
Si esta faceta codecvt define una conversión, convierte los caracteres internos de la [from, from_end) rango de origen a los caracteres externos, colocando los resultados en las ubicaciones siguientes a partir de to. Convierte no más de from_end - from caracteres internos y escribe no es más que personajes to_end - to externos. Hojas from_next y to_next señalando un más allá del último elemento convertido con éxito .
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.
Si esta faceta codecvt no define una conversión, sin caracteres se convierten. to_next se fija para ser igual a to, state es invariable, y se devuelve std::codecvt_base::noconv .
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.

Contenido

[editar] Valor de retorno

Un valor de std::codecvt_base::result tipo, que indica el estado de éxito de la siguiente manera:
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
conversión completa
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
no hay suficiente espacio en la memoria intermedia de salida o final inesperado de buffer fuente
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
encontrado un carácter que no se pudo convertir
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
esta faceta no es la conversión, no hay salida por escrito
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 especialización no convertir std::codecvt<char, char, std::mbstate_t> siempre devuelve 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.

[editar] Notas

Requiere que from <= from_end && to <= to_end state y que, o bien que representa el estado inicial de cambios o los obtenidos mediante la conversión de los caracteres anteriores en la secuencia .
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.
Mientras codecvt apoya N: M conversiones (por ejemplo, UTF-16 a UTF-8, en el que dos caracteres internos pueden ser necesarios para decidir qué caracteres externos a la salida), std::basic_filebuf sólo puede utilizar codecvt facetas que definen un 1: Conversión de N, que es debe ser capaz de procesar un carácter interno en un momento cuando se escribe en un archivo .
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.
Al realizar N: M conversiones, esta función puede devolver std::codecvt_base::partial después de consumir todos los caracteres de origen (). Esto significa que otro carácter interno que se necesita para completar la conversión (por ejemplo, al convertir UTF-16 a UTF-8, si el último carácter en el búfer de origen es un suplente 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.
El efecto sobre state es deliberadamente no especificado. En las facetas estándar, que se utiliza para mantener un estado de cambios como cuando se llama a std::wcsrtombs, y por tanto se actualiza para reflejar el estado de cambios después del último carácter convertido con éxito, sino una faceta definida por el usuario es libre de usarlo para mantener cualquier otro estado, por ejemplo, contar el número de caracteres especiales se encuentran .
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.

[editar] Ejemplo

#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';
}

Salida:

The string in narrow multibyte encoding: zß水𝄋

[editar] Ver también

[virtual]
escribe caracteres en el fichero de asociados de la zona de venta
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.

(función miembro virtual protegida de std::basic_filebuf) [editar]
convierte una cadena de ancho en una cadena de bytes
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.

(función miembro pública de std::wstring_convert) [editar]
convierte una cadena a cadena estrecha gama de caracteres multibyte, estado dado
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.

(función) [editar]
[virtual]
convierte una cadena de externT a internt, como cuando al leer el archivo
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.

(función miembro virtual protegida) [editar]