std::wcsrtombs - cppreference.com
De cppreference.com
<metanoindex/>
<tbody> </tbody>
| Definido no cabeçalho <cwchar> |
||
|
|
||
Converte uma seqüência de caracteres de largura a partir da matriz cujo primeiro elemento é apontado por *src em sua representação multibyte estreita que começa no estado de conversão descrito por *ps. Se dst não é nulo, os caracteres convertidos são armazenados nos elementos sucessivos da matriz de char apontado por dst. Não mais do que len bytes são escritos para a matriz destino.
Original:
Converts a sequence of wide characters from the array whose first element is pointed to by *src to its narrow multibyte representation that begins in the conversion state described by *ps. If dst is not null, converted characters are stored in the successive elements of the char array pointed to by dst. No more than len bytes are written to the destination array.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Cada personagem é convertido como se por uma chamada para std::wcrtomb. A conversão pára se:
Original:
Each character is converted as if by a call to std::wcrtomb. The conversion stops if:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
O caractere nulo foi convertido e armazenado.
srcestá definido para NULL e*psrepresenta o estado deslocamento inicial.Original:
The null character was converted and stored.
srcis set to NULL and*psrepresents the initial shift state.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.A
wchar_tse que não corresponde a um caractere válido na localidade C atual.srcestá definido para apontar para o caráter não convertido primeira gama.Original:
A
wchar_twas found that does not correspond to a valid character in the current C locale.srcis set to point at the first unconverted wide character.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.o caráter de multibyte próximo a ser armazenado exceder
len.srcestá definido para apontar para o caráter não convertido primeiro de largura. Esta condição não é verificado sedst==NULL.Original:
the next multibyte character to be stored would exceed
len.srcis set to point at the first unconverted wide character. This condition is not checked ifdst==NULL.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Parâmetros
| dst | - | ponteiro para matriz de caracteres estreita onde os caracteres multibyte será armazenado Original: pointer to narrow character array where the multibyte characters will be stored The text has been machine-translated via Google Translate. |
| src | - | ponteiro para ponteiro para o primeiro elemento de uma string terminada em nulo de largura Original: pointer to pointer to the first element of a null-terminated wide string The text has been machine-translated via Google Translate. |
| len | - | número de bytes disponíveis na matriz apontada por dst Original: number of bytes available in the array pointed to by dst The text has been machine-translated via Google Translate. |
| ps | - | ponteiro para o objeto de estado de conversão Original: pointer to the conversion state object The text has been machine-translated via Google Translate. |
Valor de retorno
Em caso de sucesso, retorna o número de bytes (incluindo as seqüências de turnos, mas excluindo o '\0' terminação) escritos para a matriz de caracteres cujo primeiro elemento é apontado por dst. Se dst==NULL, retorna o número de bytes que teria sido escrito.
Original:
On success, returns the number of bytes (including any shift sequences, but excluding the terminating '\0') written to the character array whose first element is pointed to by dst. If dst==NULL, returns the number of bytes that would have been written.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Em caso de erro de conversão (se inválido caráter de largura foi encontrado), retorna static_cast<std::size_t>(-1), lojas EILSEQ em errno e deixa *ps em estado indeterminado.
Original:
On conversion error (if invalid wide character was encountered), returns static_cast<std::size_t>(-1), stores EILSEQ in errno, and leaves *ps in unspecified state.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Exemplo
#include <iostream> #include <vector> #include <clocale> #include <string> #include <cwchar> void print_wide(const wchar_t* wstr) { std::mbstate_t state = std::mbstate_t(); int len = 1 + std::wcsrtombs(NULL, &wstr, 0, &state); std::vector<char> mbstr(len); std::wcsrtombs(&mbstr[0], &wstr, mbstr.size(), &state); std::cout << "multibyte string: " << &mbstr[0] << '\n' << "Length, including '\\0': " << mbstr.size() << '\n'; } int main() { std::setlocale(LC_ALL, "en_US.utf8"); // UTF-8 narrow multibyte encoding const wchar_t* wstr = L"z\u00df\u6c34\U0001d10b"; // or L"zß水𝄋" print_wide(wstr); }
Saída:
multibyte string: zß水𝄋 Length, including '\0': 11
Veja também
converte um caractere largo em sua representação multibyte, determinado estado Original: converts a wide character to its multibyte representation, given state The text has been machine-translated via Google Translate. (função) [edit] | |
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. (função) [edit] | |
[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. (virtual protegido of std::codecvt função de membro) [edit]
|
Documentação C para wcsrtombs | |