Espaços nominais
Variantes
Acções

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

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

 
 
Biblioteca localizações
Localidades e facetas
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
Classificação de caracteres
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.
Conversões
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 classes base da categoria
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.
Categorias faceta
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.
Específicos da localidade facetas
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.
Facetas de conversão de código
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 localidade
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 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)
função de membro público, chama a do_out função de membro da classe derivada mais.
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)
Se esta faceta codecvt define uma conversão, traduz os caracteres internos do [from, from_end) intervalo de origem a personagens externos, colocando os resultados nos locais posteriores a partir de to. Converte não mais do que from_end - from caracteres internos e não mais do que escreve to_end - to caracteres externos. Folhas from_next e to_next apontando um além do último elemento convertido com ê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.
Se esta faceta codecvt não define uma conversão, não são personagens convertidos. to_next é ajustado para ser igual a to, state permanece inalterado, e é retornado 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.

Índice

[editar] Valor de retorno

Um valor de std::codecvt_base::result tipo, que indica o estado de sucesso da seguinte forma:
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
conversão 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
não há espaço suficiente no buffer de saída ou fim inesperado de buffer de origem
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 um caractere que não pôde ser convertida
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 é não-conversão, sem saída 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.
A especialização não-conversão std::codecvt<char, char, std::mbstate_t> sempre retorna 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

Requer que from <= from_end && to <= to_end e que state ou que representa o estado inicial ou de deslocamento obtida pela conversão dos caracteres precedentes na sequência.
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.
Enquanto suporta codecvt N: M conversões (por exemplo, UTF-16 para UTF-8, em que dois caracteres internos pode ser necessário para decidir o que caracteres externos para a saída), std::basic_filebuf só pode utilizar as facetas que definem uma codecvt 1: N de conversão, que é deve ser capaz de processar um caráter interno no momento em que escrever em um arquivo.
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.
Ao realizar N: M conversões, esta função pode retornar std::codecvt_base::partial depois de consumir todos os caracteres de origem (). Isto significa que um outro caráter interno é necessário para concluir a conversão (por exemplo, ao converter UTF-16 para UTF-8, se o último caractere no buffer de origem é um substituto 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.
O efeito sobre state é deliberadamente não especificado. Em facetas padrão, é usado para manter o estado mudam como ao chamar std::wcsrtombs, e é, portanto, atualizado para refletir a mudança de estado após o último caractere convertido com êxito, mas uma faceta definido pelo usuário é livre para usá-lo para manter qualquer outro estado, por exemplo, contar o número de caracteres especiais encontradas.
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] Exemplo

#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ß水𝄋

[editar] Veja também

[virtual]
escreve caracteres para o arquivo associado da área de venda
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.

(virtual protegido of std::basic_filebuf função de membro) [edit]
converte uma cadeia de largura em uma seqüência 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.

(of std::wstring_convert função pública membro) [edit]
converte uma cadeia ampla de cadeia de caracteres multibyte estreita, dado estado
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.

(função) [edit]
[virtual]
Converte uma cadeia de externT a Internt, como quando lendo de um arquivo
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.

(virtual protegido função de membro) [edit]