Espaços nominais
Variantes
Acções

std::wcstombs

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.
 
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.
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.
 
Definido no cabeçalho <cstdlib>
std::size_t wcstombs( char* dst, const wchar_t* src, std::size_t len)
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 deslocamento inicial. Caracteres convertidos são armazenados nos elementos sucessivos do array 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 initial shift state. 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::wctomb, exceto que o estado do wctomb de conversão não é afetada. A conversão pára se:
Original:
Each character is converted as if by a call to std::wctomb, except that the wctomb's conversion state is unaffected. 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 personagem nulo foi convertido e armazenado.
    Original:
    The null character was converted and stored.
    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.
    Original:
    A wchar_t was found that does not correspond to a valid character in the current C locale.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • O personagem multibyte próximo a ser armazenado exceder len.
    Original:
    The next multibyte character to be stored would exceed len.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

Índice

[editar] Notas

Na maioria das implementações, esta função atualiza um objeto estático global de std::mbstate_t tipo como ele processa através da cadeia, e não pode ser chamado simultaneamente por dois fios, std::wcsrtombs deve ser usado em casos.
Original:
In most implementations, this function updates a global static object of type std::mbstate_t as it processes through the string, and cannot be called simultaneously by two threads, std::wcsrtombs should be used in such cases.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
POSIX especifica uma extensão comum: se dst é um ponteiro nulo, esta função retorna o número de bytes que seriam escritos para dst, se convertido. Comportamento semelhante é padrão para std::wcsrtombs.
Original:
POSIX specifies a common extension: if dst is a null pointer, this function returns the number of bytes that would be written to dst, if converted. Similar behavior is standard for std::wcsrtombs.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Parâmetros

dst -
ponteiro para matriz de caracteres estreita onde o personagem multibyte será armazenado
Original:
pointer to narrow character array where the multibyte character 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 o primeiro elemento de uma string terminada em null larga para converter
Original:
pointer to the first element of a null-terminated wide string to convert
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ível na matriz apontada por dst
Original:
number of byte 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.

[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.
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.
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).
Original:
On conversion error (if invalid wide character was encountered), returns static_cast<std::size_t>(-1).
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 <clocale>
#include <cstdlib>
 
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ß水𝄋"
    char mbstr[11];
    std::wcstombs(mbstr, wstr, 11);
    std::cout << "multibyte string: " << mbstr << '\n';
}

Saída:

multibyte string: zß水𝄋

[editar] Veja também

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]
converte uma cadeia de caracteres multibyte estreita para string de largura
Original:
converts a narrow multibyte character string to wide string
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]
Documentação C para wcstombs