std::codecvt::in, std::codecvt::do_in
De cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
<metanoindex/>
<tbody> </tbody>| Definido no cabeçalho <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)
função de membro público, chama a
do_in função de membro da classe derivada mais.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.
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 externos do [from, from_end) intervalo de origem a personagens internos, colocando os resultados nos locais posteriores a partir de to. Converte não mais do que from_end - from caracteres externos e não mais do que escreve to_end - to caracteres internos. 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 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.
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.
You can help to correct and verify the translation. Click here for instructions.
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.
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::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.
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.
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::mbsrtowcs, e é, portanto, atualizado para refletir o estado de conversão depois que o personagem processada por último externa, 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::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.
You can help to correct and verify the translation. Click here for instructions.
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::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';
}
Saída:
The string in wide encoding: zß水𝄋
Veja também
[virtual] |
lê o arquivo associado 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. (virtual protegido of std::basic_filebuf função de membro)
|
converte uma seqüência de bytes em uma seqüência de largura 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. (of std::wstring_convert função pública membro)
| |
converte uma cadeia de caracteres multibyte estreita para string de largura, determinado estado 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. (função) | |
[virtual] |
Converte uma cadeia de internt para externT, como ao escrever para o arquivo 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. (virtual protegido função de membro) |