std::wcstombs
Da 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. |
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.
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.
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 exceedlen
.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.
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.
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.
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.
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) | |
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) | |
[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)
|
Documentação C para wcstombs
|