Espaços nominais
Variantes
Acções

std::wcsrtombs

Da cppreference.com
< cpp‎ | string‎ | multibyte

 
 
Biblioteca cordas
Strings terminadas
Original:
Null-terminated strings
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Cadeias de bytes
Multibyte cordas
Cordas de largura
Classes
Original:
Classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_string
char_traits
 
Strings terminadas multibyte
Wide / multibyte conversões
Original:
Wide/multibyte conversions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
mbsinit
wctomb
wcstombs
wctob
wcrtomb
wcsrtombs
c16rtomb(C++11)
c32rtomb(C++11)
mbrlen
Tipos
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
mbstate_t
 
Defined in header <cwchar>
std::size_t wcsrtombs( char* dst,

                       const wchar_t** src,
                       std::size_t len,

                       std::mbstate_t* ps );
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. src está definido para NULL e *ps representa o estado deslocamento inicial.
    Original:
    The null character was converted and stored. src is set to NULL and *ps represents 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_t se que não corresponde a um caractere válido na localidade C atual. src está definido para apontar para o caráter não convertido primeira gama.
    Original:
    A wchar_t was found that does not correspond to a valid character in the current C locale. src is 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. src está definido para apontar para o caráter não convertido primeiro de largura. Esta condição não é verificado se dst==NULL.
    Original:
    the next multibyte character to be stored would exceed len. src is set to point at the first unconverted wide character. This condition is not checked if dst==NULL.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

Índice

[editar] 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.
You can help to correct and verify the translation. Click here for instructions.
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.
You can help to correct and verify the translation. Click here for instructions.
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.
You can help to correct and verify the translation. Click here for instructions.
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.
You can help to correct and verify the translation. Click here for instructions.

[editar] 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.

[editar] 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);
}

Output:

multibyte string: zß水𝄋
Length, including '\0': 11

[editar] 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.
You can help to correct and verify the translation. Click here for instructions.

(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.
You can help to correct and verify the translation. Click here for instructions.

(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.
You can help to correct and verify the translation. Click here for instructions.

(virtual protegido of std::codecvt função de membro) [edit]
C documentation for wcsrtombs